Skip to content

Commit 99e58a8

Browse files
committed
Add another fixture to trap when the environment variable changes.
1 parent f4ae416 commit 99e58a8

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

conftest.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,20 @@ def windows_only():
7676
pytest.skip("Windows only")
7777

7878

79+
class FailOnWrite(dict):
80+
def __setitem__(self, key, value):
81+
super().__setitem__(key, value)
82+
if key == 'SETUPTOOLS_USE_DISTUTILS':
83+
raise ValueError(f"Attempt to set {key} to {value}")
84+
85+
86+
@pytest.fixture(autouse=True, scope="session")
87+
def protect_os_environ():
88+
import os
89+
90+
os.environ = FailOnWrite(os.environ)
91+
92+
7993
@pytest.fixture(autouse=True)
8094
def check_setuptools_use_distutils():
8195
import os

0 commit comments

Comments
 (0)