Spaces:
Sleeping
Sleeping
Commit ·
e5283e9
1
Parent(s): d42e3af
test(env): isolate os.environ in env_loader test so it doesn't leak keys into later tests
Browse files- tests/test_env_loader.py +3 -3
tests/test_env_loader.py
CHANGED
|
@@ -12,9 +12,9 @@ def test_loads_keys_without_overriding_existing(tmp_path, monkeypatch):
|
|
| 12 |
"export ANTHROPIC_API_KEY=exported_style # inline note\n"
|
| 13 |
"ALREADY_SET=should_not_win\n"
|
| 14 |
)
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
|
| 19 |
loaded = load_dotenv(start=tmp_path)
|
| 20 |
assert loaded == str(tmp_path / ".env")
|
|
|
|
| 12 |
"export ANTHROPIC_API_KEY=exported_style # inline note\n"
|
| 13 |
"ALREADY_SET=should_not_win\n"
|
| 14 |
)
|
| 15 |
+
# Isolate os.environ to a throwaway dict so load_dotenv (which mutates the
|
| 16 |
+
# global environment) can't leak provider keys into later tests.
|
| 17 |
+
monkeypatch.setattr(os, "environ", {"ALREADY_SET": "real_env"})
|
| 18 |
|
| 19 |
loaded = load_dotenv(start=tmp_path)
|
| 20 |
assert loaded == str(tmp_path / ".env")
|