From 0d563621fbaf6e4d4ccbd0d29e829124b7c85170 Mon Sep 17 00:00:00 2001 From: vominh1919 Date: Sun, 26 Apr 2026 20:37:39 +0700 Subject: [PATCH] fix(test): skip bedrock adapter tests when botocore is not installed Six tests in test_bedrock_adapter.py import botocore.exceptions directly (ConnectionClosedError, EndpointConnectionError, ReadTimeoutError, ClientError) without guarding the import. When botocore is not installed (it's an optional dependency), these tests fail with ModuleNotFoundError instead of being gracefully skipped. Added pytest.importorskip('botocore') to each affected test function, following the same pattern used elsewhere in the test suite (e.g. test_voice_mode.py for numpy, test_mcp_oauth.py for mcp). Tests affected: - TestIsStaleConnectionError: 3 tests - TestCallConverseInvalidatesOnStaleError: 3 tests Before: 6 FAIL with ModuleNotFoundError After: 6 SKIP with reason message --- tests/agent/test_bedrock_adapter.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/agent/test_bedrock_adapter.py b/tests/agent/test_bedrock_adapter.py index 2005a6c13c..27c55cb1e9 100644 --- a/tests/agent/test_bedrock_adapter.py +++ b/tests/agent/test_bedrock_adapter.py @@ -1283,18 +1283,21 @@ class TestIsStaleConnectionError: """Classifier that decides whether an exception warrants client eviction.""" def test_detects_botocore_connection_closed_error(self): + pytest.importorskip("botocore", reason="botocore required for Bedrock exception tests") from agent.bedrock_adapter import is_stale_connection_error from botocore.exceptions import ConnectionClosedError exc = ConnectionClosedError(endpoint_url="https://bedrock.example") assert is_stale_connection_error(exc) is True def test_detects_botocore_endpoint_connection_error(self): + pytest.importorskip("botocore", reason="botocore required for Bedrock exception tests") from agent.bedrock_adapter import is_stale_connection_error from botocore.exceptions import EndpointConnectionError exc = EndpointConnectionError(endpoint_url="https://bedrock.example") assert is_stale_connection_error(exc) is True def test_detects_botocore_read_timeout(self): + pytest.importorskip("botocore", reason="botocore required for Bedrock exception tests") from agent.bedrock_adapter import is_stale_connection_error from botocore.exceptions import ReadTimeoutError exc = ReadTimeoutError(endpoint_url="https://bedrock.example") @@ -1355,6 +1358,7 @@ class TestCallConverseInvalidatesOnStaleError: reconnects instead of reusing the dead socket.""" def test_converse_evicts_client_on_stale_error(self): + pytest.importorskip("botocore", reason="botocore required for Bedrock exception tests") from agent.bedrock_adapter import ( _bedrock_runtime_client_cache, call_converse, @@ -1381,6 +1385,7 @@ class TestCallConverseInvalidatesOnStaleError: ) def test_converse_stream_evicts_client_on_stale_error(self): + pytest.importorskip("botocore", reason="botocore required for Bedrock exception tests") from agent.bedrock_adapter import ( _bedrock_runtime_client_cache, call_converse_stream, @@ -1406,6 +1411,7 @@ class TestCallConverseInvalidatesOnStaleError: def test_converse_does_not_evict_on_non_stale_error(self): """Non-stale errors (e.g. ValidationException) leave the client cache alone.""" + pytest.importorskip("botocore", reason="botocore required for Bedrock exception tests") from agent.bedrock_adapter import ( _bedrock_runtime_client_cache, call_converse,