MCPcopy Create free account
hub / github.com/anthropics/anthropic-sdk-python / without_ambient_environment

Function without_ambient_environment

tests/conftest.py:66–75  ·  view source on GitHub ↗

Removes the variables that the clients read, so that the settings of this machine cannot change a result.

(request: FixtureRequest)

Source from the content-addressed store, hash-verified

64
65@pytest.fixture(scope="session", autouse=True)
66def 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")

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected