rebase onto readme addition
This commit is contained in:
parent
603df1ea1c
commit
ee30bf45c9
|
@ -14,11 +14,22 @@ import attr
|
||||||
import pytest
|
import pytest
|
||||||
import json
|
import json
|
||||||
from os.path import sep as _sep, altsep as _altsep
|
from os.path import sep as _sep, altsep as _altsep
|
||||||
from textwrap import dedent
|
import shutil
|
||||||
|
|
||||||
from . import paths
|
from . import paths
|
||||||
from .compat import _PY2 as PY2
|
from .compat import _PY2 as PY2
|
||||||
|
|
||||||
|
README_CONTENT = u"""\
|
||||||
|
# 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.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
@attr.s
|
@attr.s
|
||||||
class Cache(object):
|
class Cache(object):
|
||||||
|
@ -104,22 +115,10 @@ class Cache(object):
|
||||||
|
|
||||||
def _ensure_readme(self):
|
def _ensure_readme(self):
|
||||||
|
|
||||||
content_readme = dedent(
|
if self._cachedir.is_dir():
|
||||||
"""\
|
readme_path = self._cachedir / "README.md"
|
||||||
# pytest cache directory #
|
if not readme_path.is_file():
|
||||||
|
readme_path.write_text(README_CONTENT)
|
||||||
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):
|
class LFPlugin(object):
|
||||||
|
@ -330,7 +329,7 @@ def cacheshow(config, session):
|
||||||
return 0
|
return 0
|
||||||
dummy = object()
|
dummy = object()
|
||||||
basedir = config.cache._cachedir
|
basedir = config.cache._cachedir
|
||||||
vdir = basedir.joinpath("v")
|
vdir = basedir / "v"
|
||||||
tw.sep("-", "cache values")
|
tw.sep("-", "cache values")
|
||||||
for valpath in sorted(x for x in vdir.rglob("*") if x.is_file()):
|
for valpath in sorted(x for x in vdir.rglob("*") if x.is_file()):
|
||||||
key = "/".join(valpath.relative_to(vdir).parts)
|
key = "/".join(valpath.relative_to(vdir).parts)
|
||||||
|
@ -342,7 +341,7 @@ def cacheshow(config, session):
|
||||||
for line in pformat(val).splitlines():
|
for line in pformat(val).splitlines():
|
||||||
tw.line(" " + line)
|
tw.line(" " + line)
|
||||||
|
|
||||||
ddir = basedir.joinpath("d")
|
ddir = basedir / "d"
|
||||||
if ddir.is_dir():
|
if ddir.is_dir():
|
||||||
contents = sorted(ddir.rglob("*"))
|
contents = sorted(ddir.rglob("*"))
|
||||||
tw.sep("-", "cache directories")
|
tw.sep("-", "cache directories")
|
||||||
|
|
|
@ -826,8 +826,8 @@ class TestReadme(object):
|
||||||
|
|
||||||
def check_readme(self, testdir):
|
def check_readme(self, testdir):
|
||||||
config = testdir.parseconfigure()
|
config = testdir.parseconfigure()
|
||||||
readme = config.cache._cachedir.join("README.md")
|
readme = config.cache._cachedir.joinpath("README.md")
|
||||||
return readme.isfile()
|
return readme.is_file()
|
||||||
|
|
||||||
def test_readme_passed(self, testdir):
|
def test_readme_passed(self, testdir):
|
||||||
testdir.makepyfile(
|
testdir.makepyfile(
|
||||||
|
|
Loading…
Reference in New Issue