diff --git a/netlib/encoding.py b/netlib/encoding.py index a3c83c46e..9b8b38688 100644 --- a/netlib/encoding.py +++ b/netlib/encoding.py @@ -162,12 +162,14 @@ def encode_deflate(content): custom_decode = { + "none": identity, "identity": identity, "gzip": decode_gzip, "deflate": decode_deflate, "br": decode_brotli, } custom_encode = { + "none": identity, "identity": identity, "gzip": encode_gzip, "deflate": encode_deflate, diff --git a/test/netlib/test_encoding.py b/test/netlib/test_encoding.py index 797abff20..e1175ef09 100644 --- a/test/netlib/test_encoding.py +++ b/test/netlib/test_encoding.py @@ -4,9 +4,13 @@ import pytest from netlib import encoding, tutils -def test_identity(): - assert b"string" == encoding.decode(b"string", "identity") - assert b"string" == encoding.encode(b"string", "identity") +@pytest.mark.parametrize("encoder", [ + 'identity', + 'none', +]) +def test_identity(encoder): + assert b"string" == encoding.decode(b"string", encoder) + assert b"string" == encoding.encode(b"string", encoder) with tutils.raises(ValueError): encoding.encode(b"string", "nonexistent encoding")