Skip to content

Commit

Permalink
Ensure cache supporting files still exist after --cache-clear
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoddemus committed Nov 30, 2019
1 parent 277857b commit 972cd74
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog/6290.bugfix.rst
@@ -0,0 +1 @@
The supporting files in the ``.pytest_cache`` directory will be properly restored after running ``--cache-clear``.
1 change: 0 additions & 1 deletion src/_pytest/cacheprovider.py
Expand Up @@ -49,7 +49,6 @@ def for_config(cls, config):
cachedir = cls.cache_dir_from_config(config)
if config.getoption("cacheclear") and cachedir.exists():
rm_rf(cachedir)
cachedir.mkdir()
return cls(cachedir, config)

@staticmethod
Expand Down
1 change: 1 addition & 0 deletions testing/test_cacheprovider.py
Expand Up @@ -270,6 +270,7 @@ def test_3(): assert 0
)
result = testdir.runpytest(str(p), "--lf", "--cache-clear")
result.stdout.fnmatch_lines(["*1 failed*2 passed*"])
assert testdir.tmpdir.join(".pytest_cache", "README.md").isfile()

# Run this again to make sure clear-cache is robust
if os.path.isdir(".pytest_cache"):
Expand Down

0 comments on commit 972cd74

Please sign in to comment.