pytest: Some internal warnings from pytest cannot be filtered with settings in pytest.ini
I want to disable PytestCacheWarning
with the following pytest.ini
file:
[pytest]
filterwarnings =
ignore::pytest.PytestCacheWarning
But the warnings are still shown in report summary. Minimal reproducible example:
pytest.ini
file as shown above- empty directory
.pytest_cache
with 444 permissions - running pytest gives the following:
~/repos/reproduce_pytest_bug$ pytest
============= test session starts =================
platform linux -- Python 3.7.6, pytest-5.3.5, py-1.8.1, pluggy-0.13.1
rootdir: /home/sanyash/repos/reproduce_pytest_bug, inifile: pytest.ini
plugins: celery-4.4.0, aiohttp-0.3.0
collected 0 items
============= warnings summary ================
/home/sanyash/.local/lib/python3.7/site-packages/_pytest/cacheprovider.py:137
/home/sanyash/.local/lib/python3.7/site-packages/_pytest/cacheprovider.py:137: PytestCacheWarning: could not create cache path /home/sanyash/repos/reproduce_pytest_bug/.pytest_cache/v/cache/stepwise
self.warn("could not create cache path {path}", path=path)
/home/sanyash/.local/lib/python3.7/site-packages/_pytest/cacheprovider.py:137
/home/sanyash/.local/lib/python3.7/site-packages/_pytest/cacheprovider.py:137: PytestCacheWarning: could not create cache path /home/sanyash/repos/reproduce_pytest_bug/.pytest_cache/v/cache/nodeids
self.warn("could not create cache path {path}", path=path)
-- Docs: https://docs.pytest.org/en/latest/warnings.html
============= 2 warnings in 0.00s =============
versions:
- Ubuntu 18.04
- Python 3.7.6
- pytest 5.3.5
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (11 by maintainers)
Commits related to this issue
- cacheprovider: use warnings directly Allows for filtering of PytestCacheWarning. Using `_issue_warning_captured` is not necessary here, and was probably only used because the cacheprovider misses wa... — committed to blueyed/pytest by blueyed 4 years ago
- Integrate warnings filtering directly into Config Warnings are a central part of Python, so much that Python itself has command-line and environtment variables to handle warnings. By moving the conc... — committed to nicoddemus/pytest by nicoddemus 4 years ago
- Integrate warnings filtering directly into Config Warnings are a central part of Python, so much that Python itself has command-line and environtment variables to handle warnings. By moving the conc... — committed to nicoddemus/pytest by nicoddemus 4 years ago
- Integrate warnings filtering directly into Config Warnings are a central part of Python, so much that Python itself has command-line and environtment variables to handle warnings. By moving the conc... — committed to nicoddemus/pytest by nicoddemus 4 years ago
- Integrate warnings filtering directly into Config Warnings are a central part of Python, so much that Python itself has command-line and environtment variables to handle warnings. By moving the conc... — committed to nicoddemus/pytest by nicoddemus 4 years ago
- Integrate warnings filtering directly into Config Warnings are a central part of Python, so much that Python itself has command-line and environtment variables to handle warnings. By moving the conc... — committed to nicoddemus/pytest by nicoddemus 4 years ago
- Integrate warnings filtering directly into Config (#7700) Warnings are a central part of Python, so much that Python itself has command-line and environtment variables to handle warnings. By movi... — committed to pytest-dev/pytest by nicoddemus 4 years ago
- Suppress DeprecationWarning from pyramid.path The warning is not new but for some reason it is now being reported with the latest pytest release. Possibly related to https://github.com/pytest-dev/pyt... — committed to hypothesis/h by robertknight 4 years ago
- Suppress DeprecationWarning from pyramid.path The warning is not new but for some reason it is now being reported with the latest pytest release. Possibly related to https://github.com/pytest-dev/pyt... — committed to hypothesis/h by robertknight 4 years ago
- Merge #6 #7 6: Pin pytest to latest version 6.2.3 r=aragilar a=pyup-bot This PR pins [pytest](https://pypi.org/project/pytest) to the latest release **6.2.3**. <details> <summary>Changelog</su... — committed to aragilar/spaceplot by bors[bot] 3 years ago
- Merge #6 6: Pin pytest to latest version 6.2.3 r=aragilar a=pyup-bot This PR pins [pytest](https://pypi.org/project/pytest) to the latest release **6.2.3**. <details> <summary>Changelog</summa... — committed to aragilar/spaceplot by bors[bot] 3 years ago
- Merge #3 #4 3: Pin sphinx_rtd_theme to latest version 0.5.1 r=aragilar a=pyup-bot This PR pins [sphinx_rtd_theme](https://pypi.org/project/sphinx_rtd_theme) to the latest release **0.5.1**. *The... — committed to aragilar/spaceplot by bors[bot] 3 years ago
- Merge #7 #8 7: Pin sphinx_rtd_theme to latest version 0.5.2 r=aragilar a=pyup-bot This PR pins [sphinx_rtd_theme](https://pypi.org/project/sphinx_rtd_theme) to the latest release **0.5.2**. *The... — committed to aragilar/spaceplot by bors[bot] 3 years ago
- Merge #4 4: Pin pytest to latest version 6.2.2 r=aragilar a=pyup-bot This PR pins [pytest](https://pypi.org/project/pytest) to the latest release **6.2.2**. <details> <summary>Changelog</summa... — committed to aragilar/spaceplot by bors[bot] 3 years ago
- Merge #18 #20 18: Pin pytest to latest version 6.2.4 r=aragilar a=pyup-bot This PR pins [pytest](https://pypi.org/project/pytest) to the latest release **6.2.4**. <details> <summary>Changelog<... — committed to aragilar/spaceplot by bors[bot] 3 years ago
- Merge #16 16: Pin pytest to latest version 6.2.4 r=aragilar a=pyup-bot This PR pins [pytest](https://pypi.org/project/pytest) to the latest release **6.2.4**. <details> <summary>Changelog</sum... — committed to aragilar/venv_tools by bors[bot] 3 years ago
@blueyed there are at least two cases:
PytestCacheWarning
because pytest is not able to write a cache.conftest_additional.py
inside mainconftest.py
and thus getPytestAssertRewriteWarning: Module already imported so cannot be rewritten: conftest_additional
. I dont know yet how to work around it.I believe that every such case can be handled in proper way, but the simplest is just disabling all internal warnings because I dont care much about them (I can be wrong here and maybe I should care, but they really don’t seem critical)
I started seeing this too with
pytest
6.0.0 that also cannot be ignored withfilterwarnings
:The config is added just in case someone has
pytest-qt
installed but it is not installed in any circumstances in the project itself. So we know it is not used and we just want to silence the warning. Thanks.