Skip to content

Commit 1d5173c

Browse files
committed
Fixed missing coverage
1 parent 7b2b429 commit 1d5173c

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

tests/test_content.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,20 @@ async def test_bytesio_content():
6565

6666
@pytest.mark.anyio
6767
async def test_async_bytesio_content():
68-
async def fixed_stream(content: bytes) -> AsyncGenerator[bytes]:
69-
yield content
68+
class AsyncBytesIO:
69+
def __init__(self, content: bytes) -> None:
70+
self._idx = 0
71+
self._content = content
7072

71-
request = httpx.Request(method, url, content=fixed_stream(b"Hello, world!"))
73+
async def aread(self, chunk_size: int) -> bytes:
74+
chunk = self._content[self._idx : self._idx + chunk_size]
75+
self._idx = self._idx + chunk_size
76+
return chunk
77+
78+
async def __aiter__(self):
79+
yield self._content # pragma: no cover
80+
81+
request = httpx.Request(method, url, content=AsyncBytesIO(b"Hello, world!"))
7282
assert not isinstance(request.stream, typing.Iterable)
7383
assert isinstance(request.stream, typing.AsyncIterable)
7484

0 commit comments

Comments
 (0)