9
9
import pytest
10
10
from respx import MockRouter
11
11
12
- from anthropic import Stream , Anthropic , AsyncStream , AsyncAnthropic
12
+ from anthropic import Anthropic , AsyncAnthropic
13
13
from anthropic ._compat import PYDANTIC_V2
14
14
from anthropic .types .beta .beta_message import BetaMessage
15
15
from anthropic .lib .streaming ._beta_types import BetaMessageStreamEvent
@@ -203,9 +203,6 @@ def assert_tool_use_response(events: list[BetaMessageStreamEvent], message: Beta
203
203
class TestSyncMessages :
204
204
@pytest .mark .respx (base_url = base_url )
205
205
def test_basic_response (self , respx_mock : MockRouter ) -> None :
206
- # skip for now... this isn't in `stream`?
207
- pytest .skip ("Deprecated model warnings are not currently implemented for streaming..." )
208
-
209
206
respx_mock .post ("/v1/messages" ).mock (return_value = httpx .Response (200 , content = basic_response ()))
210
207
211
208
with sync_client .beta .messages .stream (
@@ -218,8 +215,7 @@ def test_basic_response(self, respx_mock: MockRouter) -> None:
218
215
],
219
216
model = "claude-3-opus-20240229" ,
220
217
) as stream :
221
- with pytest .warns (DeprecationWarning ):
222
- assert isinstance (cast (Any , stream ), Stream )
218
+ assert isinstance (cast (Any , stream ), BetaMessageStream )
223
219
224
220
assert_basic_response ([event for event in stream ], stream .get_final_message ())
225
221
@@ -264,8 +260,6 @@ def test_context_manager(self, respx_mock: MockRouter) -> None:
264
260
265
261
@pytest .mark .respx (base_url = base_url )
266
262
def test_deprecated_model_warning_stream (self , respx_mock : MockRouter ) -> None :
267
- # skip for now... this isn't in `stream`?
268
- pytest .skip ("Deprecated model warnings are not currently implemented for streaming..." )
269
263
for deprecated_model in DEPRECATED_MODELS :
270
264
respx_mock .post ("/v1/messages" ).mock (return_value = httpx .Response (200 , content = basic_response ()))
271
265
@@ -283,8 +277,6 @@ class TestAsyncMessages:
283
277
@pytest .mark .asyncio
284
278
@pytest .mark .respx (base_url = base_url )
285
279
async def test_basic_response (self , respx_mock : MockRouter ) -> None :
286
- # skip for now... this isn't in `stream`?
287
- pytest .skip ("Deprecated model warnings are not currently implemented for streaming..." )
288
280
respx_mock .post ("/v1/messages" ).mock (return_value = httpx .Response (200 , content = to_async_iter (basic_response ())))
289
281
290
282
async with async_client .beta .messages .stream (
@@ -295,10 +287,9 @@ async def test_basic_response(self, respx_mock: MockRouter) -> None:
295
287
"content" : "Say hello there!" ,
296
288
}
297
289
],
298
- model = "claude-3- opus-20240229 " ,
290
+ model = "claude-opus-4-0 " ,
299
291
) as stream :
300
- with pytest .warns (DeprecationWarning ):
301
- assert isinstance (cast (Any , stream ), AsyncStream )
292
+ assert isinstance (cast (Any , stream ), BetaAsyncMessageStream )
302
293
303
294
assert_basic_response ([event async for event in stream ], await stream .get_final_message ())
304
295
@@ -325,8 +316,6 @@ async def test_context_manager(self, respx_mock: MockRouter) -> None:
325
316
@pytest .mark .asyncio
326
317
@pytest .mark .respx (base_url = base_url )
327
318
async def test_deprecated_model_warning_stream (self , respx_mock : MockRouter ) -> None :
328
- # skip for now... this isn't in `stream`?
329
- pytest .skip ("Deprecated model warnings are not currently implemented for streaming..." )
330
319
for deprecated_model in DEPRECATED_MODELS :
331
320
respx_mock .post ("/v1/messages" ).mock (
332
321
return_value = httpx .Response (200 , content = to_async_iter (basic_response ()))
@@ -394,6 +383,7 @@ def test_stream_method_definition_in_sync(sync: bool) -> None:
394
383
+ "\n \n " .join (errors )
395
384
)
396
385
386
+
397
387
# go through all the ContentBlock types to make sure the type alias is up to date
398
388
# with any type that has an input property of type object
399
389
def test_tracks_tool_input_type_alias_is_up_to_date () -> None :
0 commit comments