From 75e467cb157a1f85164a1717d78c98e2fb95684f Mon Sep 17 00:00:00 2001 From: Safal Gupta <148842438+alphasafal@users.noreply.github.com> Date: Thu, 22 Oct 2026 08:52:44 +0530 Subject: [PATCH 1/3] chore(tests): clear ambient AWS env vars in the Mantle and AWS client tests --- tests/lib/test_bedrock_mantle.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/lib/test_bedrock_mantle.py b/tests/lib/test_bedrock_mantle.py index 6aa1bb393..34c09a0fe 100644 --- a/tests/lib/test_bedrock_mantle.py +++ b/tests/lib/test_bedrock_mantle.py @@ -18,6 +18,20 @@ MODEL = "anthropic.claude-sonnet-4-5" +@pytest.fixture(autouse=True) +def isolate_env(monkeypatch: pytest.MonkeyPatch) -> None: + """Keep AWS settings from the developer's shell out of these tests.""" + for name in ( + "AWS_REGION", + "AWS_DEFAULT_REGION", + "AWS_PROFILE", + "AWS_BEARER_TOKEN_BEDROCK", + "ANTHROPIC_AWS_API_KEY", + "ANTHROPIC_BEDROCK_MANTLE_BASE_URL", + ): + monkeypatch.delenv(name, raising=False) + + class GetAuthHeadersRecorder: """Stands in for `anthropic.lib.bedrock._mantle.get_auth_headers` and records each call's kwargs.""" From 27bda19d2447c1b6201029299334ab3cc5db6349 Mon Sep 17 00:00:00 2001 From: Safal Gupta <148842438+alphasafal@users.noreply.github.com> Date: Thu, 22 Oct 2026 08:54:34 +0530 Subject: [PATCH 2/3] chore(tests): clear ambient AWS env vars in the Mantle and AWS client tests --- tests/lib/test_aws_auth.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/lib/test_aws_auth.py b/tests/lib/test_aws_auth.py index e0e95fcf7..29a22902b 100644 --- a/tests/lib/test_aws_auth.py +++ b/tests/lib/test_aws_auth.py @@ -15,6 +15,22 @@ validate_credentials, ) + +@pytest.fixture(autouse=True) +def isolate_env(monkeypatch: pytest.MonkeyPatch) -> None: + """Keep AWS settings from the developer's shell out of these tests.""" + for name in ( + "AWS_REGION", + "AWS_DEFAULT_REGION", + "AWS_PROFILE", + "AWS_BEARER_TOKEN_BEDROCK", + "ANTHROPIC_AWS_API_KEY", + "ANTHROPIC_AWS_BASE_URL", + "ANTHROPIC_AWS_WORKSPACE_ID", + ): + monkeypatch.delenv(name, raising=False) + + # --- validate_credentials --- From 6f01639d6c8617b2efa24e2d4d51b417a937c2b8 Mon Sep 17 00:00:00 2001 From: Safal Gupta <148842438+alphasafal@users.noreply.github.com> Date: Thu, 22 Oct 2026 08:56:59 +0530 Subject: [PATCH 3/3] chore(tests): clear ambient AWS env vars in the Mantle and AWS client tests --- tests/lib/test_aws.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/lib/test_aws.py b/tests/lib/test_aws.py index a571f85cf..377fdc3aa 100644 --- a/tests/lib/test_aws.py +++ b/tests/lib/test_aws.py @@ -135,6 +135,13 @@ def _clear_aws_url_env(monkeypatch: pytest.MonkeyPatch) -> None: monkeypatch.delenv(var, raising=False) +@pytest.fixture(autouse=True) +def isolate_env(monkeypatch: pytest.MonkeyPatch) -> None: + """Keep AWS settings from the developer's shell out of these tests.""" + _clear_aws_url_env(monkeypatch) + monkeypatch.delenv("ANTHROPIC_AWS_API_KEY", raising=False) + + def _set_ambient_first_party_credentials(monkeypatch: pytest.MonkeyPatch) -> None: monkeypatch.setenv("ANTHROPIC_API_KEY", "ambient-key") monkeypatch.setenv("ANTHROPIC_AUTH_TOKEN", "ambient-token")