Skip to content

Commit f61e683

Browse files
committed
Add test
1 parent 9bae78c commit f61e683

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/smithy-core/tests/unit/aio/test_types.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import asyncio
44
from io import BytesIO
55
from typing import Self
6+
from unittest.mock import Mock
67

78
import pytest
89

@@ -96,14 +97,18 @@ async def test_read_async_iterator() -> None:
9697
assert await reader.read() == b"foo"
9798
assert source.tell() == 3
9899

99-
source = BytesIO(b"foo,bar,baz\n")
100+
source = Mock(wraps=BytesIO(b"foo,bar,baz\n"))
100101
reader = AsyncBytesReader(_AsyncIteratorWrapper(source, chunk_size=6))
101102
assert source.tell() == 0
102103
assert await reader.read(4) == b"foo,"
103104
assert source.tell() == 6
104105
assert await reader.read(4) == b"bar,"
105106
assert source.tell() == 12
107+
108+
assert source.read.call_count == 2
106109
assert await reader.read(4) == b"baz\n"
110+
# sufficient bytes have been read from source, assert we don't call read again
111+
assert source.read.call_count == 2
107112
assert source.tell() == 12
108113

109114

0 commit comments

Comments
 (0)