Skip to content

Commit c8a6ec3

Browse files
fix tests
1 parent 7bd7ed4 commit c8a6ec3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tests/integrations/anthropic/test_anthropic.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ async def __call__(self, *args, **kwargs):
1313

1414

1515
from anthropic import Anthropic, AnthropicError, AsyncAnthropic
16-
from anthropic.lib.streaming import TextEvent
1716
from anthropic.types import MessageDeltaUsage, TextDelta, Usage
1817
from anthropic.types.content_block_delta_event import ContentBlockDeltaEvent
1918
from anthropic.types.content_block_start_event import ContentBlockStartEvent
@@ -30,6 +29,11 @@ async def __call__(self, *args, **kwargs):
3029
except ImportError:
3130
pass
3231

32+
try:
33+
from anthropic.lib.streaming import TextEvent
34+
except ImportError:
35+
TextEvent = None
36+
3337
try:
3438
# 0.27+
3539
from anthropic.types.raw_message_delta_event import Delta
@@ -818,7 +822,7 @@ def test_stream_messages_iterator_methods(
818822
next(stream)
819823
list(islice(stream, 1))
820824
# New versions add TextEvent, so consume one more event.
821-
if isinstance(next(stream), TextEvent):
825+
if TextEvent is not None and isinstance(next(stream), TextEvent):
822826
next(stream)
823827
stream.close()
824828

0 commit comments

Comments
 (0)