pytester now requests monkeypatch instead of creating its own instance
It is tempting to use `monkeypatch` to replace the other mechanisms in pytester which change global state: `CwdSnapshot`, `SysModulesSnapshot`, `SysPathsSnapshot`, however those are more delicate than they look at first glance so leaving those alone for now. Close #9708
This commit is contained in:
committed by
Anthony Sottile
parent
9318b2cb7f
commit
f943d1944a
@@ -618,14 +618,9 @@ def test_linematcher_string_api() -> None:
|
||||
|
||||
|
||||
def test_pytest_addopts_before_pytester(request, monkeypatch: MonkeyPatch) -> None:
|
||||
orig = os.environ.get("PYTEST_ADDOPTS", None)
|
||||
monkeypatch.setenv("PYTEST_ADDOPTS", "--orig-unused")
|
||||
pytester: Pytester = request.getfixturevalue("pytester")
|
||||
_: Pytester = request.getfixturevalue("pytester")
|
||||
assert "PYTEST_ADDOPTS" not in os.environ
|
||||
pytester._finalize()
|
||||
assert os.environ.get("PYTEST_ADDOPTS") == "--orig-unused"
|
||||
monkeypatch.undo()
|
||||
assert os.environ.get("PYTEST_ADDOPTS") == orig
|
||||
|
||||
|
||||
def test_run_stdin(pytester: Pytester) -> None:
|
||||
|
||||
Reference in New Issue
Block a user