(self, browser: Browser)
| 565 | assert response.is_stream_consumed is True # type: ignore[unreachable] # Mypy can't detect a change of state |
| 566 | |
| 567 | async def test_iter_bytes(self, browser: Browser) -> None: |
| 568 | impit = AsyncClient(browser=browser) |
| 569 | |
| 570 | async with impit.stream('GET', get_httpbin_url('/')) as response: |
| 571 | assert response.status_code == 200 |
| 572 | assert response.is_closed is False |
| 573 | assert response.is_stream_consumed is False |
| 574 | |
| 575 | content = b''.join([item async for item in response.aiter_bytes()]) |
| 576 | |
| 577 | assert isinstance(content, bytes) |
| 578 | assert len(content) > 0 |
| 579 | |
| 580 | # After `iter_bytes`` we should get an error since `content` and `text` are not cached |
| 581 | with pytest.raises(StreamConsumed): |
| 582 | _ = response.text |
| 583 | |
| 584 | with pytest.raises(StreamConsumed): |
| 585 | _ = response.content |
| 586 | |
| 587 | assert response.is_closed is True |
| 588 | assert response.is_stream_consumed is True # type: ignore[unreachable] # Mypy can't detect a change of state |
| 589 | |
| 590 | async def test_response_with_context_manager(self, browser: Browser) -> None: |
| 591 | impit = AsyncClient(browser=browser) |
nothing calls this directly
no test coverage detected