added changelog entry
moved cache readme tests to test_cacheprovider.py
This commit is contained in:
parent
8f1d8ac970
commit
c672bfa32e
|
@ -0,0 +1 @@
|
|||
now `.pytest_cache` is created with a README.md to indicate it's usage,options etc.
|
|
@ -15,6 +15,7 @@ import pytest
|
|||
import json
|
||||
import os
|
||||
from os.path import sep as _sep, altsep as _altsep
|
||||
from textwrap import dedent
|
||||
|
||||
|
||||
class Cache(object):
|
||||
|
@ -106,15 +107,19 @@ class Cache(object):
|
|||
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.
|
||||
content_readme = dedent(
|
||||
"""\
|
||||
# pytest cache directory #
|
||||
|
||||
**Do not** commit this to version control.
|
||||
This directory contains data from the pytest's cache plugin,\
|
||||
which provides the `--lf` and `--ff` options, as well as the `cache` fixture.
|
||||
|
||||
See [the docs](https://docs.pytest.org/en/latest/cache.html) for more information.
|
||||
**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):
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
from __future__ import absolute_import, division, print_function
|
||||
import _pytest
|
||||
|
||||
pytest_plugins = ("pytester",)
|
||||
|
||||
|
||||
class Helper(object):
|
||||
|
||||
def check_readme(self, testdir):
|
||||
config = testdir.parseconfigure()
|
||||
readme = config.cache._cachedir.join("README.md")
|
||||
return readme.isfile()
|
||||
|
||||
|
||||
class TestReadme(Helper):
|
||||
|
||||
def test_readme_passed(self, testdir):
|
||||
testdir.tmpdir.join("test_a.py").write(
|
||||
_pytest._code.Source(
|
||||
"""
|
||||
def test_always_passes():
|
||||
assert 1
|
||||
"""
|
||||
)
|
||||
)
|
||||
testdir.runpytest()
|
||||
assert self.check_readme(testdir) is True
|
||||
|
||||
def test_readme_failed(self, testdir):
|
||||
testdir.tmpdir.join("test_a.py").write(
|
||||
_pytest._code.Source(
|
||||
"""
|
||||
def test_always_passes():
|
||||
assert 0
|
||||
"""
|
||||
)
|
||||
)
|
||||
testdir.runpytest()
|
||||
assert self.check_readme(testdir) is True
|
|
@ -6,7 +6,7 @@ import pytest
|
|||
import os
|
||||
import shutil
|
||||
|
||||
pytest_plugins = "pytester",
|
||||
pytest_plugins = ("pytester",)
|
||||
|
||||
|
||||
class TestNewAPI(object):
|
||||
|
@ -818,3 +818,31 @@ class TestNewFirst(object):
|
|||
"*test_1/test_1.py::test_1[2*",
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
class TestReadme(object):
|
||||
|
||||
def check_readme(self, testdir):
|
||||
config = testdir.parseconfigure()
|
||||
readme = config.cache._cachedir.join("README.md")
|
||||
return readme.isfile()
|
||||
|
||||
def test_readme_passed(self, testdir):
|
||||
testdir.makepyfile(
|
||||
"""
|
||||
def test_always_passes():
|
||||
assert 1
|
||||
"""
|
||||
)
|
||||
testdir.runpytest()
|
||||
assert self.check_readme(testdir) is True
|
||||
|
||||
def test_readme_failed(self, testdir):
|
||||
testdir.makepyfile(
|
||||
"""
|
||||
def test_always_passes():
|
||||
assert 0
|
||||
"""
|
||||
)
|
||||
testdir.runpytest()
|
||||
assert self.check_readme(testdir) is True
|
||||
|
|
Loading…
Reference in New Issue