Skip to content

Commit 336b2ee

Browse files
skip error tests on old versions
1 parent c08fd2c commit 336b2ee

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

tests/integrations/anthropic/test_anthropic.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,14 @@ async def __call__(self, *args, **kwargs):
2020
from anthropic.types.message import Message
2121
from anthropic.types.message_delta_event import MessageDeltaEvent
2222
from anthropic.types.message_start_event import MessageStartEvent
23-
from anthropic.types import ErrorResponse, OverloadedError
24-
from anthropic import APIStatusError
23+
24+
try:
25+
from anthropic.types import ErrorResponse, OverloadedError
26+
from anthropic import APIStatusError
27+
except ImportError:
28+
ErrorResponse = None
29+
OverloadedError = None
30+
APIStatusError = None
2531

2632
try:
2733
from anthropic.types import InputJSONDelta
@@ -534,6 +540,10 @@ def test_streaming_create_message_iterator_methods(
534540
assert span["data"][SPANDATA.GEN_AI_RESPONSE_ID] == "msg_01XFDUDYJgAACzvnptvVoYEL"
535541

536542

543+
@pytest.mark.skipif(
544+
ANTHROPIC_VERSION < (0, 41),
545+
reason="Error classes moved in https://github.com/anthropics/anthropic-sdk-python/commit/4e0b15e22fe40e9aa513459564f641bf97c90954.",
546+
)
537547
def test_streaming_create_message_api_error(
538548
sentry_init,
539549
capture_events,
@@ -954,6 +964,10 @@ def test_stream_messages_iterator_methods(
954964
assert span["data"][SPANDATA.GEN_AI_RESPONSE_ID] == "msg_01XFDUDYJgAACzvnptvVoYEL"
955965

956966

967+
@pytest.mark.skipif(
968+
ANTHROPIC_VERSION < (0, 41),
969+
reason="Error classes moved in https://github.com/anthropics/anthropic-sdk-python/commit/4e0b15e22fe40e9aa513459564f641bf97c90954.",
970+
)
957971
def test_stream_messages_api_error(
958972
sentry_init,
959973
capture_events,
@@ -1385,6 +1399,10 @@ async def test_streaming_create_message_async_iterator_methods(
13851399
assert span["data"][SPANDATA.GEN_AI_RESPONSE_ID] == "msg_01XFDUDYJgAACzvnptvVoYEL"
13861400

13871401

1402+
@pytest.mark.skipif(
1403+
ANTHROPIC_VERSION < (0, 41),
1404+
reason="Error classes moved in https://github.com/anthropics/anthropic-sdk-python/commit/4e0b15e22fe40e9aa513459564f641bf97c90954.",
1405+
)
13881406
@pytest.mark.asyncio
13891407
async def test_streaming_create_message_async_api_error(
13901408
sentry_init,
@@ -1712,6 +1730,10 @@ async def test_stream_messages_async_next_consumption(
17121730
assert span["data"][SPANDATA.GEN_AI_RESPONSE_ID] == "msg_01XFDUDYJgAACzvnptvVoYEL"
17131731

17141732

1733+
@pytest.mark.skipif(
1734+
ANTHROPIC_VERSION < (0, 41),
1735+
reason="Error classes moved in https://github.com/anthropics/anthropic-sdk-python/commit/4e0b15e22fe40e9aa513459564f641bf97c90954.",
1736+
)
17151737
@pytest.mark.asyncio
17161738
async def test_stream_messages_async_api_error(
17171739
sentry_init,

0 commit comments

Comments
 (0)