Search code examples
pythonunit-testingdeprecatedsuppress-warnings

nosetest deprecation warnings


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.


Solution

  • Put

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

    at the start of your test script, before you import any problematic libraries.