MCPcopy
hub / github.com/pytest-dev/pytest / test_cache_show

Function test_cache_show

testing/test_cacheprovider.py:232–281  ·  view source on GitHub ↗
(pytester: Pytester)

Source from the content-addressed store, hash-verified

230
231
232def test_cache_show(pytester: Pytester) -> None:
233 result = pytester.runpytest("--cache-show")
234 assert result.ret == 0
235 result.stdout.fnmatch_lines(["*cache is empty*"])
236 pytester.makeconftest(
237 """
238 def pytest_configure(config):
239 config.cache.set("my/name", [1,2,3])
240 config.cache.set("my/hello", "world")
241 config.cache.set("other/some", {1:2})
242 dp = config.cache.mkdir("mydb")
243 dp.joinpath("hello").touch()
244 dp.joinpath("world").touch()
245 """
246 )
247 result = pytester.runpytest()
248 assert result.ret == 5 # no tests executed
249
250 result = pytester.runpytest("--cache-show")
251 result.stdout.fnmatch_lines(
252 [
253 "*cachedir:*",
254 "*- cache values for '[*]' -*",
255 "cache/nodeids contains:",
256 "my/name contains:",
257 " [1, 2, 3]",
258 "other/some contains:",
259 " {*'1': 2}",
260 "*- cache directories for '[*]' -*",
261 "*mydb/hello*length 0*",
262 "*mydb/world*length 0*",
263 ]
264 )
265 assert result.ret == 0
266
267 result = pytester.runpytest("--cache-show", "*/hello")
268 result.stdout.fnmatch_lines(
269 [
270 "*cachedir:*",
271 "*- cache values for '[*]/hello' -*",
272 "my/hello contains:",
273 " *'world'",
274 "*- cache directories for '[*]/hello' -*",
275 "d/mydb/hello*length 0*",
276 ]
277 )
278 stdout = result.stdout.str()
279 assert "other/some" not in stdout
280 assert "d/mydb/world" not in stdout
281 assert result.ret == 0
282
283
284class TestLastFailed:

Callers

nothing calls this directly

Calls 4

fnmatch_linesMethod · 0.80
strMethod · 0.80
runpytestMethod · 0.45
makeconftestMethod · 0.45

Tested by

no test coverage detected