MCPcopy Create free account
hub / github.com/apify/impit / test_iter_bytes

Method test_iter_bytes

impit-python/test/basic_client_test.py:540–561  ·  view source on GitHub ↗
(self, browser: Browser)

Source from the content-addressed store, hash-verified

538 assert response.is_stream_consumed is True # type: ignore[unreachable] # Mypy can't detect a change of state
539
540 def test_iter_bytes(self, browser: Browser) -> None:
541 impit = Client(browser=browser)
542
543 with impit.stream('GET', get_httpbin_url('/')) as response:
544 assert response.status_code == 200
545 assert response.is_closed is False
546 assert response.is_stream_consumed is False
547
548 content = b''.join(response.iter_bytes())
549
550 assert isinstance(content, bytes)
551 assert len(content) > 0
552
553 # After `iter_bytes`` we should get an error since `content` and `text` are not cached
554 with pytest.raises(StreamConsumed):
555 _ = response.text
556
557 with pytest.raises(StreamConsumed):
558 _ = response.content
559
560 assert response.is_closed is True
561 assert response.is_stream_consumed is True # type: ignore[unreachable] # Mypy can't detect a change of state
562
563 def test_response_with_context_manager(self, browser: Browser) -> None:
564 impit = Client(browser=browser)

Callers

nothing calls this directly

Calls 4

streamMethod · 0.95
ClientClass · 0.90
get_httpbin_urlFunction · 0.85
iter_bytesMethod · 0.80

Tested by

no test coverage detected