Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle warnings raised at import time early in pytest process #12249

Open
Redoubts opened this issue Apr 26, 2024 · 0 comments
Open

Handle warnings raised at import time early in pytest process #12249

Redoubts opened this issue Apr 26, 2024 · 0 comments
Labels
plugin: warnings related to the warnings builtin plugin type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature

Comments

@Redoubts
Copy link

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
...
@Zac-HD Zac-HD added type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature plugin: warnings related to the warnings builtin plugin labels May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: warnings related to the warnings builtin plugin type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature
Projects
None yet
Development

No branches or pull requests

2 participants