mitmproxy/test/test_encoding.py

38 lines
886 B
Python
Raw Normal View History

from netlib import encoding
2015-08-10 18:44:36 +00:00
def test_identity():
assert "string" == encoding.decode("identity", "string")
assert "string" == encoding.encode("identity", "string")
assert not encoding.encode("nonexistent", "string")
assert None == encoding.decode("nonexistent encoding", "string")
def test_gzip():
2015-09-15 17:12:15 +00:00
assert b"string" == encoding.decode(
"gzip",
encoding.encode(
"gzip",
2015-09-15 17:12:15 +00:00
b"string"
)
)
assert encoding.decode("gzip", b"bogus") is None
def test_deflate():
2015-09-15 17:12:15 +00:00
assert b"string" == encoding.decode(
"deflate",
encoding.encode(
"deflate",
2015-09-15 17:12:15 +00:00
b"string"
)
)
assert b"string" == encoding.decode(
"deflate",
encoding.encode(
"deflate",
2015-09-15 17:12:15 +00:00
b"string"
)[2:-4]
)
assert encoding.decode("deflate", b"bogus") is None