From 1b77dcf8caa533eeb24c2a10a7d0ffad2896dd79 Mon Sep 17 00:00:00 2001 From: Branch Vincent Date: Wed, 27 Apr 2022 17:29:01 -0400 Subject: [PATCH] test: isolate environment from user config --- tests/conftest.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index d2d52feb0c6..6253f50fbd2 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -234,6 +234,21 @@ def environ() -> Iterator[None]: os.environ.update(original_environ) +@pytest.fixture(autouse=True) +def isolate_environ() -> Iterator[None]: + """Ensure the environment is isolated from user configuration.""" + original_environ = dict(os.environ) + + for var in os.environ: + if var.startswith("POETRY_"): + del os.environ[var] + + yield + + os.environ.clear() + os.environ.update(original_environ) + + @pytest.fixture(autouse=True) def git_mock(mocker: MockerFixture) -> None: # Patch git module to not actually clone projects