Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline Brotli samples in tests #2935

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 3 additions & 5 deletions tests/test_decoders.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import typing
import zlib

import brotli
import chardet
import pytest

Expand Down Expand Up @@ -61,7 +60,7 @@ def test_gzip():

def test_brotli():
body = b"test 123"
compressed_body = brotli.compress(body)
compressed_body = b"\x8b\x03\x80test 123\x03"

headers = [(b"Content-Encoding", b"br")]
response = httpx.Response(
Expand Down Expand Up @@ -94,7 +93,7 @@ def test_multi():

def test_multi_with_identity():
body = b"test 123"
compressed_body = brotli.compress(body)
compressed_body = b"\x8b\x03\x80test 123\x03"

headers = [(b"Content-Encoding", b"br, identity")]
response = httpx.Response(
Expand Down Expand Up @@ -153,8 +152,7 @@ def test_decoders_empty_cases(header_value):
@pytest.mark.parametrize("header_value", (b"deflate", b"gzip", b"br"))
def test_decoding_errors(header_value):
headers = [(b"Content-Encoding", header_value)]
body = b"test 123"
compressed_body = brotli.compress(body)[3:]
compressed_body = b"invalid"
with pytest.raises(httpx.DecodingError):
request = httpx.Request("GET", "https://example.org")
httpx.Response(200, headers=headers, content=compressed_body, request=request)
Expand Down