pytest-warnings
raw JSON → 0.3.1 verified Fri May 01 auth: no python maintenance
A pytest plugin that lists Python warnings in the pytest report. Version 0.3.1. Low release cadence, last updated in 2020.
pip install pytest-warnings Common errors
error ERROR: usage: pytest [options] [file_or_dir] [...] pytest: error: unrecognized arguments: --no-header ↓
cause Potential conflict with other plugins or pytest version. The plugin may add arguments that conflict.
fix
Upgrade pytest or add
-p no:warnings temporarily to disable. Check if the plugin is compatible with your pytest version. error ModuleNotFoundError: No module named 'pytest_warnings' ↓
cause Package not installed or misspelled in conftest.py.
fix
Run
pip install pytest-warnings and ensure the name in conftest.py is pytest_warnings. Warnings
deprecated pytest-warnings is largely superseded by built-in '-W' flag and pytest's native warning capture. Consider using native pytest features. ↓
fix Use `pytest -W error::UserWarning` or configure `filterwarnings` in pytest.ini.
gotcha The plugin is imported via 'pytest_warnings' (underscore) but installed as 'pytest-warnings' (hyphen). ↓
fix Use underscore in conftest.py: `pytest_plugins = ['pytest_warnings']`.
Imports
- pytest-warnings wrong
import pytest_warningscorrectpytest_plugins = ['pytest_warnings']
Quickstart
# conftest.py
pytest_plugins = ['pytest_warnings']
# Then run pytest normally; warnings will appear in the report summary.