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 warnings during
`pytest_sessionfinish`, which is also fixed here.

I think the usage of `_issue_warning_captured` can be removed/reduced
further, but also that this is good enough for now.

Ref: https://github.com/pytest-dev/pytest/issues/6681.
This commit is contained in:
Daniel Hahler
2020-02-11 13:10:51 +01:00
parent 67e69a7e49
commit 02aa8adae1
3 changed files with 12 additions and 5 deletions

View File

@@ -56,9 +56,7 @@ class TestNewAPI:
testdir.tmpdir.ensure_dir(".pytest_cache").chmod(mode)
@pytest.mark.skipif(sys.platform.startswith("win"), reason="no chmod on windows")
@pytest.mark.filterwarnings(
"ignore:could not create cache path:pytest.PytestWarning"
)
@pytest.mark.filterwarnings("default")
def test_cache_failure_warns(self, testdir, monkeypatch):
monkeypatch.setenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", "1")
cache_dir = str(testdir.tmpdir.ensure_dir(".pytest_cache"))