From 31f089db6ade6e345f4cab23fe4fa0a838c34f47 Mon Sep 17 00:00:00 2001 From: avirlrma Date: Thu, 21 Jun 2018 13:10:42 +0530 Subject: [PATCH] add reamde for .pytest_cache method - `ensure_readme()` --- src/_pytest/cacheprovider.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/_pytest/cacheprovider.py b/src/_pytest/cacheprovider.py index eb0fcc06f..ff2d1e285 100755 --- a/src/_pytest/cacheprovider.py +++ b/src/_pytest/cacheprovider.py @@ -103,6 +103,22 @@ class Cache(object): with f: self.trace("cache-write %s: %r" % (key, value)) json.dump(value, f, indent=2, sort_keys=True) + self._ensure_readme() + + def _ensure_readme(self): + content_readme = '''# pytest cache directory # + +This directory contains data from the pytest's cache plugin, \ +which provides the `--lf` and `--ff` options, as well as the `cache` fixture. + +**Do not** commit this to version control. + +See [the docs](https://docs.pytest.org/en/latest/cache.html) for more information. + ''' + if self._cachedir.check(dir=True): + readme_path = self._cachedir.join("README.md") + if not readme_path.check(file=True): + readme_path.write(content_readme) class LFPlugin(object):