tests.test_http moduleΒΆ

Tests for the shared HTTP fetch and cache mechanics.

tests.test_http.test_get_json_retries_incomplete_read(truncations)[source]ΒΆ

A truncated body is retried after each pause of the backoff.

tests.test_http.test_get_json_persistent_incomplete_read()[source]ΒΆ

A body truncated on every retry raises FetchError.

tests.test_http.test_get_text_decodes_body()[source]ΒΆ

A text fetch returns the decoded body rather than a parsed value.

tests.test_http.test_get_text_rejects_undecodable_body()[source]ΒΆ

A body that is not UTF-8 is a failed fetch, not mojibake.

tests.test_http.test_get_text_retries_incomplete_read()[source]ΒΆ

A truncated text body earns the same retries as a JSON one.

tests.test_http.test_get_cached_json_fetches_and_stores()[source]ΒΆ

A cache miss fetches over HTTP and stores the raw response body.

tests.test_http.test_get_cached_json_uses_cache_when_fresh()[source]ΒΆ

A cache hit is parsed and returned without any HTTP request.

tests.test_http.test_get_cached_json_ignores_corrupt_cache()[source]ΒΆ

A cache entry that no longer parses falls through to a fresh fetch.

tests.test_http.test_get_cached_json_returns_none_on_fetch_error(patch_kwargs)[source]ΒΆ

An HTTP, network or parse failure is swallowed into a None result.

tests.test_http.test_get_cached_json_skips_store_when_ttl_disabled()[source]ΒΆ

With caching disabled (ttl == 0), a fetched body is not stored.

tests.test_http.test_get_json_soft_forwards_headers()[source]ΒΆ

A soft read sends the caller’s headers over the JSON default.

tests.test_http.test_get_json_soft_misses_quietly()[source]ΒΆ

A failure is a None, not an exception.

tests.test_http.test_request_returns_status_headers_and_body()[source]ΒΆ

A response comes back whole, its headers keyed by lowercase name.

tests.test_http.test_request_keeps_the_status_and_body_of_an_http_error()[source]ΒΆ

An error status reaches the caller with the start of its body.

tests.test_http.test_error_excerpt_reads_an_unreadable_body_as_empty()[source]ΒΆ

A body the connection cuts short leaves the refusal without its detail.

tests.test_http.test_request_wraps_every_transport_failure(failure)[source]ΒΆ

A dropped, reset or stalled connection is a FetchError with no status.

tests.test_http.test_request_wraps_a_malformed_url()[source]ΒΆ

A URL urllib cannot open fails like any other fetch.

tests.test_http.test_request_retries_a_truncated_body_only_when_safe(method, attempts)[source]ΒΆ

Only a request safe to repeat is sent again after a truncated body.

tests.test_http.GZIP_HEADERS = {'Content-Encoding': 'gzip'}ΒΆ

Response headers of a gzip body, spelled as a server sends them.

tests.test_http.test_request_asks_for_gzip_and_decodes_it()[source]ΒΆ

A gzip body comes back decoded, its headers as the server sent them.

tests.test_http.test_request_lets_the_caller_refuse_gzip()[source]ΒΆ

A caller header replaces the Accept-Encoding default.

tests.test_http.test_get_json_retries_a_cut_off_gzip_body()[source]ΒΆ

A gzip stream that ends early is a truncated body, so it is retried.

tests.test_http.test_request_refuses_a_corrupt_gzip_body()[source]ΒΆ

A body that claims gzip but is not gzip fails without a retry.

tests.test_http.test_error_excerpt_decodes_a_gzip_body()[source]ΒΆ

The excerpt of a gzip error body is text, not compressed bytes.

tests.test_http.test_download_streams_the_body_and_returns_its_digest(tmp_path)[source]ΒΆ

The body lands in the file, and its SHA-256 comes back.

tests.test_http.test_download_retries_only_what_can_change(tmp_path, failures, attempts, succeeds)[source]ΒΆ

A network fault or a server error is tried again; a client error is not.

tests.test_http.test_download_refuses_a_truncated_body(tmp_path)[source]ΒΆ

A body shorter than its Content-Length fails, and leaves no file.

tests.test_http.test_download_keeps_a_credential_off_the_redirect(tmp_path)[source]ΒΆ

An unredirected header reaches the URL alone, never its redirect target.

tests.test_http.test_suite_refuses_an_unmocked_fetch()[source]ΒΆ

A fetch that no test stubbed fails at once.

The _no_real_http fixture of tests/conftest.py holds this. The .invalid domain never resolves, so a suite that lost the fixture fails here on the message instead of reaching a real host.

tests.test_http.test_real_http_marker_lifts_the_refusal()[source]ΒΆ

A test marked real_http reaches the real urlopen.

The opt-out of the tests that run a registry tool for real: on a cold cache their probe downloads the pinned binary through this module. See skip_unless_tool_runs in tests/conftest.py.