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