Skip to content

Some internal warnings from pytest cannot be filtered with settings in pytest.ini #6681

Closed
@sanyassh

Description

@sanyassh

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:

  1. pytest.ini file as shown above
  2. empty directory .pytest_cache with 444 permissions
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    plugin: warningsrelated to the warnings builtin plugintopic: configrelated to config handling, argument parsing and config filetype: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions