MCPcopy
hub / github.com/encode/httpx / clean_environ

Function clean_environ

tests/conftest.py:35–48  ·  tests/conftest.py::clean_environ

Keeps os.environ clean for every test without having to mock os.environ

()

Source from the content-addressed store, hash-verified

33
34@pytest.fixture(scope=class="st">"function", autouse=True)
35def clean_environ():
36 class="st">""class="st">"Keeps os.environ clean for every test without having to mock os.environ"class="st">""
37 original_environ = os.environ.copy()
38 os.environ.clear()
39 os.environ.update(
40 {
41 k: v
42 for k, v in original_environ.items()
43 if k not in ENVIRONMENT_VARIABLES and k.lower() not in ENVIRONMENT_VARIABLES
44 }
45 )
46 yield
47 os.environ.clear()
48 os.environ.update(original_environ)
49
50
51Message = typing.Dict[str, typing.Any]

Callers

nothing calls this directly

Calls 4

copyMethod · 0.80
clearMethod · 0.80
updateMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected