Skip Menu |

This queue is for tickets about the Test-Warnings CPAN distribution.

Report information
The Basics
Id: 127106
Status: open
Priority: 0/
Queue: Test-Warnings

People
Owner: Nobody in particular
Requestors: PETDANCE [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Add a function for allow_warnings { block }
I've recently switch to Test::Warnings from Test::NoWarnings, and now I'm doing search & destroy on tests that throw warnings. It would be nice if I could do something like: allow_warnings_in_this_block { code(); code(); code(); }; I've been doing: allow_warnings(1); code();code();code(); allow_warnings(0); or my $ignore = warnings { code(); code(); }; and neither is very satisfying.
Show quoted text
> It would be nice if I could do something like: > > allow_warnings_in_this_block { > code(); code(); code(); > };
I just ran into such a usecase myself today. I ended up doing this: warnings(sub { ... stuff that might generate warnings ... }); So I think a allow_warnings(&) or warnings_ok(&) would probably just be an alias to the current 'warnings' sub. It would be nicer to have this though (as you suggested in the other ticket): allow_warnings([ qr/.../, ...], sub { ... });
Show quoted text
> I just ran into such a usecase myself today. I ended up doing this: > > warnings(sub { > ... stuff that might generate warnings ... > });
So you're just capturing the warnings and then ignoring them? Kinda sneaky, but not obvious. An alias for clarity would be good.