I often get lots of deprecations from libraries that are outside my control and I do not want to pollute test executions with them.
How can I avoid this without risking to disable deprecations from my own code?
Example:
================================================================================ warnings summary ==================================================================================
.tox/py27-ansible25-unit/lib/python3.6/site-packages/toml/decoder.py:47
/Users/ssbarnea/os/molecule/.tox/py27-ansible25-unit/lib/python3.6/site-packages/toml/decoder.py:47: DeprecationWarning: invalid escape sequence \.
TIME_RE = re.compile("([0-9]{2}):([0-9]{2}):([0-9]{2})(\.([0-9]{3,6}))?")
.tox/py27-ansible25-unit/lib/python3.6/site-packages/sh.py:424
/Users/ssbarnea/os/molecule/.tox/py27-ansible25-unit/lib/python3.6/site-packages/sh.py:424: DeprecationWarning: invalid escape sequence \d
rc_exc_regex = re.compile("(ErrorReturnCode|SignalException)_((\d+)|SIG[a-zA-Z]+)")
.tox/py27-ansible25-unit/lib/python3.6/site-packages/botocore/vendored/requests/packages/urllib3/connectionpool.py:152
/Users/ssbarnea/os/molecule/.tox/py27-ansible25-unit/lib/python3.6/site-packages/botocore/vendored/requests/packages/urllib3/connectionpool.py:152: DeprecationWarning: invalid escape sequence \*
I won't repeat pytest
docs on the general topic of warnings capturing, for the sake of reference: Warnings Capture. From here, you can narrow the warnings captured by stricter filters. The filter format is
{action}:{message}:{category}:{module}:{lineno}
with elements skippable. Examples to paste in your pytest.ini
, from general to specific:
[pytest]
filterwarnings =
ignore:
DeprecationWarning
s[pytest]
filterwarnings =
ignore::DeprecationWarning
DeprecationWarning
s with invalid escape sequence
in message[pytest]
filterwarnings =
ignore:.*invalid escape sequence.*:DeprecationWarning
DeprecationWarning
s only in toml.decoder
module[pytest]
filterwarnings =
ignore::DeprecationWarning:toml.decoder
DeprecationWarning
s only in toml.decoder
module on line 47[pytest]
filterwarnings =
ignore::DeprecationWarning:toml.decoder:47
DeprecationWarning
s only in toml.decoder
module, only on line 47 and only with invalid escape sequence
in message:[pytest]
filterwarnings =
ignore:.*invalid escape sequence.*:DeprecationWarning:toml.decoder:47
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With