MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_cache_failure_warns

Method test_cache_failure_warns

testing/test_cacheprovider.py:72–94  ·  view source on GitHub ↗
(
        self,
        pytester: Pytester,
        monkeypatch: MonkeyPatch,
        unwritable_cache_dir: Path,
    )

Source from the content-addressed store, hash-verified

70
71 @pytest.mark.filterwarnings("default")
72 def test_cache_failure_warns(
73 self,
74 pytester: Pytester,
75 monkeypatch: MonkeyPatch,
76 unwritable_cache_dir: Path,
77 ) -> None:
78 monkeypatch.setenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", "1")
79
80 pytester.makepyfile("def test_error(): raise Exception")
81 result = pytester.runpytest()
82 assert result.ret == 1
83 # warnings from nodeids, lastfailed, and stepwise
84 result.stdout.fnmatch_lines(
85 [
86 # Validate location/stacklevel of warning from cacheprovider.
87 "*= warnings summary =*",
88 "*/cacheprovider.py:*",
89 " */cacheprovider.py:*: PytestCacheWarning: could not create cache path "
90 f"{unwritable_cache_dir}/v/cache/nodeids",
91 ' config.cache.set("cache/nodeids", sorted(self.cached_nodeids))',
92 "*1 failed, 3 warnings in*",
93 ]
94 )
95
96 def test_config_cache(self, pytester: Pytester) -> None:
97 pytester.makeconftest(

Callers

nothing calls this directly

Calls 4

setenvMethod · 0.80
fnmatch_linesMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected