[Numpy-discussion] Set FutureWarnings to error in (dev) tests?

Sebastian Berg sebastian at sipsolutions.net
Thu Jan 21 20:00:43 EST 2016


On Do, 2016-01-21 at 16:51 -0800, Nathaniel Smith wrote:
> On Thu, Jan 21, 2016 at 4:44 PM, Sebastian Berg
> <sebastian at sipsolutions.net> wrote:
> > On Do, 2016-01-21 at 16:15 -0800, Nathaniel Smith wrote:
> > > On Thu, Jan 21, 2016 at 4:05 PM, Sebastian Berg
> > > <sebastian at sipsolutions.net> wrote:
> > > > Hi all,
> > > > 
> > > > should we try to set FutureWarnings to errors in dev tests? I
> > > > am
> > > > seriously annoyed by FutureWarnings getting lost all over for
> > > > two
> > > > reasons. First, it is hard to impossible to find even our own
> > > > errors
> > > > for our own FutureWarning changes. Secondly, we currently would
> > > > not
> > > > even see any Futurewarnings from someone else. For numpy that
> > > > may
> > > > not
> > > > be a big issue, but still.
> > > 
> > > Yeah, I noticed this recently too :-(. Definitely it is the right
> > > thing to do, I think. And this is actually more true the more
> > > annoying
> > > it is, because if we're triggering lots of FutureWarnings then we
> > > should fix that :-).
> > > 
> > 
> > Yeah, the problem is that some FutureWarnings that are given in the
> > dozens. Injecting the filter on the module level is possible, but
> > not
> > quite correct. Maybe one could do evil things similar to a "module
> > decorator" to add the warning context + filter to every single
> > function
> > in a module starting with "test_".
> 
> Can we remove the FutureWarnings by making whatever change they're
> warning about? :-)
> 

That would be equivalent of not issueing the futurewarning at all ;).
Well, you can write a context manager and put this stuff into the

if __name__ == '__main__':

block actually. It is still annoying, since ideally we want to filter a
single warning, which means the necessaty to install our own warning
printer.


> > Another method could be to abuse `__warningregistry__`, but there
> > are
> > at least two reasons why this is probably not viable (nevermind
> > that it
> > would be ugly as well).
> > 
> > Doesn't nose maybe provide *something*? I mean seriously, testing
> > warnings tends to be hell broke lose? Change one thing, suddenly
> > dozens
> > appear from nowhere, never sure you found all cases, etc.
> 
> AFAICT nose doesn't provide much of anything for working with
> warnings. :-/
> 
> -n
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20160122/2e607600/attachment.sig>


More information about the NumPy-Discussion mailing list