88
99import httpx
1010from httpx ._content import AsyncIteratorByteStream
11- from httpx ._types import AsyncFile
11+ from httpx ._types import AsyncReadableBinaryFile , is_async_readable_binary_file
1212
1313method = "POST"
1414url = "https://www.example.com"
@@ -537,7 +537,9 @@ def echo_request_content(request: httpx.Request) -> httpx.Response:
537537 to_upload = tmp_path / "upload.txt"
538538 to_upload .write_bytes (content_bytes )
539539
540- async def checks (client : httpx .AsyncClient , async_file : AsyncFile ) -> None :
540+ async def checks (
541+ client : httpx .AsyncClient , async_file : AsyncReadableBinaryFile
542+ ) -> None :
541543 read_called = 0
542544 fileno_called = 0
543545 original_read = async_file .read
@@ -572,7 +574,7 @@ def mock_fileno(*args):
572574 transport = httpx .MockTransport (echo_request_content )
573575 ) as client ,
574576 ):
575- assert isinstance (async_file , AsyncFile )
577+ assert is_async_readable_binary_file (async_file )
576578 await checks (client , async_file )
577579
578580 if anyio_backend != "trio" : # aiofiles doesn't work with trio
@@ -582,5 +584,5 @@ def mock_fileno(*args):
582584 transport = httpx .MockTransport (echo_request_content )
583585 ) as client ,
584586 ):
585- assert isinstance (aio_file , AsyncFile )
587+ assert is_async_readable_binary_file (aio_file )
586588 await checks (client , aio_file )
0 commit comments