Removes the variables that the clients read, so that the settings of this machine cannot change a result.
(request: FixtureRequest)
| 64 | |
| 65 | @pytest.fixture(scope="session", autouse=True) |
| 66 | def without_ambient_environment(request: FixtureRequest) -> Iterator[None]: |
| 67 | """Removes the variables that the clients read, so that the settings of this machine cannot change a result.""" |
| 68 | with pytest.MonkeyPatch.context() as monkeypatch: |
| 69 | # A live or a recording run sends real requests, which need the real settings. |
| 70 | if os.environ.get("ANTHROPIC_LIVE") != "1" and not request.config.getoption("--http-record"): |
| 71 | for name in list(os.environ): |
| 72 | if name.startswith(("ANTHROPIC_", "AWS_")): |
| 73 | monkeypatch.delenv(name) |
| 74 | |
| 75 | yield |
| 76 | |
| 77 | |
| 78 | @pytest.fixture(scope="session") |