Open
Description
As noted in #12248, some modules can raise warnings at import time. If this happens during AssertionRewritingHook
's actions, then they get raised early and cannot be controlled by the pytest filterwarnings
config, which is unfortunate. There should be a good way to suppress these with normal pytest config options.
Currently witnessing this on platform linux -- Python 3.11.9, pytest-8.1.1, pluggy-1.4.0
Example issue:
% pytest some_test.py
<venv>/lib/python3.11/site-packages/_pytest/assertion/rewrite.py:178: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
exec(co, module.__dict__)
<venv>/lib/python3.11/site-packages/pkg_resources/__init__.py:2832: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('sphinxcontrib')`.
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
declare_namespace(pkg)
============================================= test session starts =============================================
platform linux -- Python 3.11.9, pytest-8.1.1, pluggy-1.4.0
...