Skip to content
Myr

Inline Brotli samples in tests (#2935)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Inline the compressed Brotli samples in tests to make them independent of Brotli implementation. This makes it possible to run the test suite both against Brotli and brotlicffi. Fixes #2906

authored by Michał Górny · committed by GitHub · parent fbe35ad · Browse files · 1 file+3 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+3 added−5 removed

  • tests:+3 added−5 removed

1 file+3 added−5 removed

modified:tests/test_decoders.py+3 added-5 removed
1import typing2import zlib34import brotli4import chardet5import pytest67import httpx
51 unmodified lines
596061def test_brotli():62 body = b"test 123"64 compressed_body = brotli.compress(body)63 compressed_body = b"\x8b\x03\x80test 123\x03"6465 headers = [(b"Content-Encoding", b"br")]66 response = httpx.Response(67 200,
24 unmodified lines
929394def test_multi_with_identity():95 body = b"test 123"97 compressed_body = brotli.compress(body)96 compressed_body = b"\x8b\x03\x80test 123\x03"9798 headers = [(b"Content-Encoding", b"br, identity")]99 response = httpx.Response(100 200,
50 unmodified lines
151152@pytest.mark.parametrize("header_value", (b"deflate", b"gzip", b"br"))153def test_decoding_errors(header_value):154 headers = [(b"Content-Encoding", header_value)]156 body = b"test 123"157 compressed_body = brotli.compress(body)[3:]155 compressed_body = b"invalid"156 with pytest.raises(httpx.DecodingError):157 request = httpx.Request("GET", "https://example.org")158 httpx.Response(200, headers=headers, content=compressed_body, request=request)159
115 unmodified lines