|
14 | 14 | pytest_plugins = ("pytester",)
|
15 | 15 |
|
16 | 16 |
|
| 17 | +@pytest.fixture(scope="function", autouse=True) |
| 18 | +def handle_env(monkeypatch): |
| 19 | + """Ensure env is like most of the tests expect it, i.e. not using tox.""" |
| 20 | + monkeypatch.delenv("TOX_ENV_DIR", raising=False) |
| 21 | + |
| 22 | + |
17 | 23 | class TestNewAPI(object):
|
18 | 24 | def test_config_cache_makedir(self, testdir):
|
19 | 25 | testdir.makeini("[pytest]")
|
@@ -148,15 +154,17 @@ def test_custom_cache_dir_with_env_var(self, testdir, monkeypatch):
|
148 | 154 | assert testdir.tmpdir.join("custom_cache_dir").isdir()
|
149 | 155 |
|
150 | 156 |
|
151 |
| -def test_cache_reportheader(testdir): |
152 |
| - testdir.makepyfile( |
153 |
| - """ |
154 |
| - def test_hello(): |
155 |
| - pass |
156 |
| - """ |
157 |
| - ) |
| 157 | +@pytest.mark.parametrize("env", ((), ("TOX_ENV_DIR", "/tox_env_dir"))) |
| 158 | +def test_cache_reportheader(env, testdir, monkeypatch): |
| 159 | + testdir.makepyfile("""def test_foo(): pass""") |
| 160 | + if env: |
| 161 | + monkeypatch.setenv(*env) |
| 162 | + expected = os.path.join(env[1], ".pytest_cache") |
| 163 | + else: |
| 164 | + monkeypatch.delenv("TOX_ENV_DIR", raising=False) |
| 165 | + expected = ".pytest_cache" |
158 | 166 | result = testdir.runpytest("-v")
|
159 |
| - result.stdout.fnmatch_lines(["cachedir: .pytest_cache"]) |
| 167 | + result.stdout.fnmatch_lines(["cachedir: %s" % expected]) |
160 | 168 |
|
161 | 169 |
|
162 | 170 | def test_cache_reportheader_external_abspath(testdir, tmpdir_factory):
|
|
0 commit comments