|
4 | 4 | import pytest |
5 | 5 |
|
6 | 6 | from aiohttp import streams |
| 7 | +from aiohttp.base_protocol import BaseProtocol |
7 | 8 |
|
8 | 9 |
|
9 | 10 | @pytest.fixture |
@@ -112,6 +113,15 @@ async def test_read_nowait(self, stream) -> None: |
112 | 113 | assert res == b"" |
113 | 114 | assert stream._protocol.resume_reading.call_count == 1 # type: ignore[attr-defined] |
114 | 115 |
|
| 116 | + async def test_resumed_on_eof(self, stream: streams.StreamReader) -> None: |
| 117 | + stream.feed_data(b"data") |
| 118 | + assert stream._protocol.pause_reading.call_count == 1 # type: ignore[attr-defined] |
| 119 | + assert stream._protocol.resume_reading.call_count == 0 # type: ignore[attr-defined] |
| 120 | + stream._protocol._reading_paused = True |
| 121 | + |
| 122 | + stream.feed_eof() |
| 123 | + assert stream._protocol.resume_reading.call_count == 1 # type: ignore[attr-defined] |
| 124 | + |
115 | 125 |
|
116 | 126 | async def test_flow_control_data_queue_waiter_cancelled( |
117 | 127 | buffer: streams.FlowControlDataQueue, |
@@ -180,3 +190,16 @@ async def test_flow_control_data_queue_read_eof( |
180 | 190 | buffer.feed_eof() |
181 | 191 | with pytest.raises(streams.EofStream): |
182 | 192 | await buffer.read() |
| 193 | + |
| 194 | + |
| 195 | +async def test_stream_reader_eof_when_full() -> None: |
| 196 | + loop = asyncio.get_event_loop() |
| 197 | + protocol = BaseProtocol(loop=loop) |
| 198 | + protocol.transport = asyncio.Transport() |
| 199 | + stream = streams.StreamReader(protocol, 1024, loop=loop) |
| 200 | + |
| 201 | + data_len = stream._high_water + 1 |
| 202 | + stream.feed_data(b"0" * data_len) |
| 203 | + assert protocol._reading_paused |
| 204 | + stream.feed_eof() |
| 205 | + assert not protocol._reading_paused |
0 commit comments