1

We recently updated to pytest-6.2 and have discovered a dependency that is quite noisy with DeprecationWarning: invalid escape sequence warnings, which I know needs fixing, but is out of my control.

This noise is a distraction from the module under test, and I would like to suppress these warnings

I have added the following to my pytest.ini

filterwarnings =
    ignore::DeprecationWarning:module_name.*

And suppressions work for things like:

 DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working

But I still get invalid escape sequence warnings:

DeprecationWarning: invalid escape sequence \s

Is there are reason for this?

4
  • Does this help? stackoverflow.com/a/50821160/11246056
    – Laurent
    May 20, 2021 at 6:41
  • Thats where I got the syntax and example for mine above, so it helped, but it doesn't answer the specific question about DeprecationWarning: invalid escape sequence
    – Adam Clark
    May 20, 2021 at 8:44
  • 1
    ignore:*.invalid escape sequence.*:DeprecationWarning:?
    – hoefling
    May 20, 2021 at 22:19
  • Yup, that works, but also includes my modules, I just want to hide noisy dependencies for which I have little/no control.
    – Adam Clark
    May 22, 2021 at 8:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.