File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
packages/smithy-core/tests/unit/aio Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change 33import asyncio
44from io import BytesIO
55from typing import Self
6+ from unittest .mock import Mock
67
78import 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
You can’t perform that action at this time.
0 commit comments