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

Function test_gitignore

testing/test_cacheprovider.py:1196–1210  ·  view source on GitHub ↗

Ensure we automatically create .gitignore file in the pytest_cache directory (#3286).

(pytester: Pytester)

Source from the content-addressed store, hash-verified

1194
1195
1196def test_gitignore(pytester: Pytester) -> None:
1197 """Ensure we automatically create .gitignore file in the pytest_cache directory (#3286)."""
1198 from _pytest.cacheprovider import Cache
1199
1200 config = pytester.parseconfig()
1201 cache = Cache.for_config(config, _ispytest=True)
1202 cache.set("foo", "bar")
1203 msg = "# Created by pytest automatically.\n*\n"
1204 gitignore_path = cache._cachedir.joinpath(".gitignore")
1205 assert gitignore_path.read_text(encoding="UTF-8") == msg
1206
1207 # Does not overwrite existing/custom one.
1208 gitignore_path.write_text("custom")
1209 cache.set("something", "else")
1210 assert gitignore_path.read_text(encoding="UTF-8") == "custom"
1211
1212
1213def test_preserve_keys_order(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 3

for_configMethod · 0.80
setMethod · 0.80
parseconfigMethod · 0.45

Tested by

no test coverage detected