views:

39

answers:

1

I am getting deprecation warnings from nosetest for 3rd party modules imported by my code.

Does anybody know how to silence these warnings?

I know of the following flag which works for arbitrary python runs of the same code:

 python -W ignore::DeprecationWarning

But, calling nosetest does not appear to offer me a similar flag to prevent the warnings from appearing within the test reports.

A: 

Put

import warnings
warnings.filterwarnings('ignore', category=DeprecationWarning)

inside your test script.

unutbu
@landstatic: Sorry for being unclear. I meant that the above code should be placed in "test.py" -- the script that you write.
unutbu
@unutbu that did not appear to help unfortunately. My test.py imports implementation.py :-) that in turns imports thirdparty.py that is the cause of my deprecation warning woes... My test.py fixtures kick of python subprocesses which were also generating warnings due to dependency on the same 3rd party library, but I fixed those by adding the -W ignore::DeprecationWarning, so that just leaves nosetest's own Python process to blame for the warnings appearing on the console. Unless I am missing something.
landstatic
@landstatic: Did you put the `warnings.filterwarnings` command before all the other imports?
unutbu
@unutbu that will be the problem...*slapping forehead*
landstatic