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

Method test_iter_bytes

impit-python/test/no_client_test.py:340–359  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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:

Callers

nothing calls this directly

Calls 3

get_httpbin_urlFunction · 0.85
iter_bytesMethod · 0.80
streamMethod · 0.45

Tested by

no test coverage detected