Ensure we automatically create .gitignore file in the pytest_cache directory (#3286).
(pytester: Pytester)
| 1194 | |
| 1195 | |
| 1196 | def 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 | |
| 1213 | def test_preserve_keys_order(pytester: Pytester) -> None: |
nothing calls this directly
no test coverage detected