diff options
author | Daniel Hahler <git@thequod.de> | 2019-11-18 16:00:01 +0100 |
---|---|---|
committer | Daniel Hahler <git@thequod.de> | 2019-11-22 21:50:31 +0100 |
commit | b0ebcfb7857ef9e14064ca22baad4f6623f0251a (patch) | |
tree | 764718f2ec4ada44a63bb74c60e27a5d22b6d52d /testing/test_pytester.py | |
parent | 2fa0518e899dd8750770c5e62db6528198e7fe4d (diff) | |
download | pytest-b0ebcfb7857ef9e14064ca22baad4f6623f0251a.tar.gz |
pytester: remove special handling of env during inner runs
Closes https://github.com/pytest-dev/pytest/issues/6213.
Diffstat (limited to 'testing/test_pytester.py')
-rw-r--r-- | testing/test_pytester.py | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/testing/test_pytester.py b/testing/test_pytester.py index 5bdbacdd0..3dab13b4b 100644 --- a/testing/test_pytester.py +++ b/testing/test_pytester.py @@ -550,17 +550,15 @@ def test_no_matching_after_match(): assert str(e.value).splitlines() == ["fnmatch: '*'", " with: '1'"] -def test_pytester_addopts(request, monkeypatch): +def test_pytester_addopts_before_testdir(request, monkeypatch): + orig = os.environ.get("PYTEST_ADDOPTS", None) monkeypatch.setenv("PYTEST_ADDOPTS", "--orig-unused") - testdir = request.getfixturevalue("testdir") - - try: - assert "PYTEST_ADDOPTS" not in os.environ - finally: - testdir.finalize() - - assert os.environ["PYTEST_ADDOPTS"] == "--orig-unused" + assert "PYTEST_ADDOPTS" not in os.environ + testdir.finalize() + assert os.environ.get("PYTEST_ADDOPTS") == "--orig-unused" + monkeypatch.undo() + assert os.environ.get("PYTEST_ADDOPTS") == orig def test_run_stdin(testdir): @@ -640,14 +638,10 @@ def test_popen_default_stdin_stderr_and_stdin_None(testdir): def test_spawn_uses_tmphome(testdir): - import os - tmphome = str(testdir.tmpdir) + assert os.environ.get("HOME") == tmphome - # Does use HOME only during run. - assert os.environ.get("HOME") != tmphome - - testdir._env_run_update["CUSTOMENV"] = "42" + testdir.monkeypatch.setenv("CUSTOMENV", "42") p1 = testdir.makepyfile( """ |