From 1c12e7c2b8bc04a2b01e21ac58771bc958a8ac8a Mon Sep 17 00:00:00 2001 From: Thomas Kriechbaumer Date: Sat, 1 Aug 2015 14:53:13 +0200 Subject: [PATCH] move encoding tests from mitmproxy to netlib --- test/test_encoding.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 test/test_encoding.py diff --git a/test/test_encoding.py b/test/test_encoding.py new file mode 100644 index 000000000..faf718ae6 --- /dev/null +++ b/test/test_encoding.py @@ -0,0 +1,32 @@ +from netlib import encoding + +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(): + assert "string" == encoding.decode( + "gzip", + encoding.encode( + "gzip", + "string")) + assert None == encoding.decode("gzip", "bogus") + + +def test_deflate(): + assert "string" == encoding.decode( + "deflate", + encoding.encode( + "deflate", + "string")) + assert "string" == encoding.decode( + "deflate", + encoding.encode( + "deflate", + "string")[ + 2:- + 4]) + assert None == encoding.decode("deflate", "bogus")