(self)
| 338 | assert response.is_stream_consumed is True # type: ignore[unreachable] # Mypy can't detect a change of state |
| 339 | |
| 340 | def test_iter_bytes(self) -> None: |
| 341 | with impit.stream('GET', get_httpbin_url('/')) as response: |
| 342 | assert response.status_code == 200 |
| 343 | assert response.is_closed is False |
| 344 | assert response.is_stream_consumed is False |
| 345 | |
| 346 | content = b''.join(response.iter_bytes()) |
| 347 | |
| 348 | assert isinstance(content, bytes) |
| 349 | assert len(content) > 0 |
| 350 | |
| 351 | # After `iter_bytes`` we should get an error since `content` and `text` are not cached |
| 352 | with pytest.raises(StreamConsumed): |
| 353 | _ = response.text |
| 354 | |
| 355 | with pytest.raises(StreamConsumed): |
| 356 | _ = response.content |
| 357 | |
| 358 | assert response.is_closed is True |
| 359 | assert response.is_stream_consumed is True # type: ignore[unreachable] # Mypy can't detect a change of state |
| 360 | |
| 361 | def test_response_with_context_manager(self) -> None: |
| 362 | with impit.stream('GET', get_httpbin_url('/')) as response: |
nothing calls this directly
no test coverage detected