cache_dir: use $TOX_ENV_DIR/ prefix if set
Fixes https://github.com/pytest-dev/pytest/issues/4270
This commit is contained in:
@@ -14,6 +14,17 @@ import pytest
|
||||
pytest_plugins = ("pytester",)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module", autouse=True)
|
||||
def handle_env():
|
||||
"""Ensure env is like most of the tests expect it, i.e. not using tox."""
|
||||
orig_env = os.environ.pop("TOX_ENV_DIR", None)
|
||||
|
||||
yield
|
||||
|
||||
if orig_env is not None:
|
||||
os.environ["TOX_ENV_DIR"] = orig_env
|
||||
|
||||
|
||||
class TestNewAPI(object):
|
||||
def test_config_cache_makedir(self, testdir):
|
||||
testdir.makeini("[pytest]")
|
||||
@@ -148,15 +159,17 @@ class TestNewAPI(object):
|
||||
assert testdir.tmpdir.join("custom_cache_dir").isdir()
|
||||
|
||||
|
||||
def test_cache_reportheader(testdir):
|
||||
testdir.makepyfile(
|
||||
"""
|
||||
def test_hello():
|
||||
pass
|
||||
"""
|
||||
)
|
||||
@pytest.mark.parametrize("env", ((), ("TOX_ENV_DIR", "/tox_env_dir")))
|
||||
def test_cache_reportheader(env, testdir, monkeypatch):
|
||||
testdir.makepyfile("""def test_foo(): pass""")
|
||||
if env:
|
||||
monkeypatch.setenv(*env)
|
||||
expected = os.path.join(env[1], ".pytest_cache")
|
||||
else:
|
||||
monkeypatch.delenv("TOX_ENV_DIR", raising=False)
|
||||
expected = ".pytest_cache"
|
||||
result = testdir.runpytest("-v")
|
||||
result.stdout.fnmatch_lines(["cachedir: .pytest_cache"])
|
||||
result.stdout.fnmatch_lines(["cachedir: %s" % expected])
|
||||
|
||||
|
||||
def test_cache_reportheader_external_abspath(testdir, tmpdir_factory):
|
||||
|
||||
Reference in New Issue
Block a user