aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@corte.si>2016-09-05 10:15:23 +1200
committerGitHub <noreply@github.com>2016-09-05 10:15:23 +1200
commitc76d83f749079b88a2b7b7a76545a7d571ed96a5 (patch)
tree6e3df5338cbd413b308506bdbf6641d52aa33e2c /test
parent0483486c628d0e590231ed44bf5a3656122c543e (diff)
parentc0b12da40108899d9bf470d14a460f6ca4efaa5d (diff)
downloadmitmproxy-c76d83f749079b88a2b7b7a76545a7d571ed96a5.tar.gz
mitmproxy-c76d83f749079b88a2b7b7a76545a7d571ed96a5.tar.bz2
mitmproxy-c76d83f749079b88a2b7b7a76545a7d571ed96a5.zip
Merge pull request #1515 from Kriechi/bump-brotli
bump brotli dependency
Diffstat (limited to 'test')
-rw-r--r--test/netlib/test_encoding.py49
1 files changed, 18 insertions, 31 deletions
diff --git a/test/netlib/test_encoding.py b/test/netlib/test_encoding.py
index 08e69ec5..797abff2 100644
--- a/test/netlib/test_encoding.py
+++ b/test/netlib/test_encoding.py
@@ -1,4 +1,6 @@
import mock
+import pytest
+
from netlib import encoding, tutils
@@ -9,47 +11,32 @@ def test_identity():
encoding.encode(b"string", "nonexistent encoding")
-def test_gzip():
- assert b"string" == encoding.decode(
- encoding.encode(
- b"string",
- "gzip"
- ),
- "gzip"
- )
- with tutils.raises(ValueError):
- encoding.decode(b"bogus", "gzip")
+@pytest.mark.parametrize("encoder", [
+ 'gzip',
+ 'br',
+ 'deflate',
+])
+def test_encoders(encoder):
+ assert "" == encoding.decode("", encoder)
+ assert b"" == encoding.decode(b"", encoder)
-
-def test_brotli():
- assert b"string" == encoding.decode(
+ assert "string" == encoding.decode(
encoding.encode(
- b"string",
- "br"
+ "string",
+ encoder
),
- "br"
+ encoder
)
- with tutils.raises(ValueError):
- encoding.decode(b"bogus", "br")
-
-
-def test_deflate():
assert b"string" == encoding.decode(
encoding.encode(
b"string",
- "deflate"
+ encoder
),
- "deflate"
- )
- assert b"string" == encoding.decode(
- encoding.encode(
- b"string",
- "deflate"
- )[2:-4],
- "deflate"
+ encoder
)
+
with tutils.raises(ValueError):
- encoding.decode(b"bogus", "deflate")
+ encoding.decode(b"foobar", encoder)
def test_cache():