aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2016-07-04 13:58:09 -0700
committerMaximilian Hils <git@maximilianhils.com>2016-07-04 13:58:09 -0700
commita6b3551934e2b8768177d6831ca08f97f5bdae44 (patch)
tree39fd8a2223b726b7b496b93ed55ade32e9ebf05e /test
parent2f8a1fd2cb1374941f436f36bbfa0d0b3d9213c7 (diff)
downloadmitmproxy-a6b3551934e2b8768177d6831ca08f97f5bdae44.tar.gz
mitmproxy-a6b3551934e2b8768177d6831ca08f97f5bdae44.tar.bz2
mitmproxy-a6b3551934e2b8768177d6831ca08f97f5bdae44.zip
raise ValueError if content-encoding is invalid
Diffstat (limited to 'test')
-rw-r--r--test/netlib/http/test_message.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/test/netlib/http/test_message.py b/test/netlib/http/test_message.py
index e1707a91..ed7d3da5 100644
--- a/test/netlib/http/test_message.py
+++ b/test/netlib/http/test_message.py
@@ -5,7 +5,7 @@ import mock
import six
from netlib.tutils import tresp
-from netlib import http
+from netlib import http, tutils
def _test_passthrough_attr(message, attr):
@@ -92,9 +92,6 @@ class TestMessage(object):
assert resp.data.content == b"bar"
assert resp.headers["content-length"] == "0"
- def test_content_basic(self):
- _test_passthrough_attr(tresp(), "content")
-
def test_headers(self):
_test_passthrough_attr(tresp(), "headers")
@@ -149,18 +146,22 @@ class TestMessageContentEncoding(object):
r = tresp()
r.headers["content-encoding"] = "zopfli"
r.raw_content = b"foo"
- assert r.content == b"foo"
+ with tutils.raises(ValueError):
+ assert r.content
assert r.headers["content-encoding"]
def test_cannot_decode(self):
r = tresp()
r.encode("gzip")
r.raw_content = b"foo"
- assert r.content == b"foo"
+ with tutils.raises(ValueError):
+ assert r.content
assert r.headers["content-encoding"]
- r.decode()
+
+ with tutils.raises(ValueError):
+ r.decode()
assert r.raw_content == b"foo"
- assert "content-encoding" not in r.headers
+ assert "content-encoding" in r.headers
def test_cannot_encode(self):
r = tresp()
@@ -213,6 +214,7 @@ class TestMessageText(object):
r.encode("identity")
with mock.patch("netlib.encoding.encode") as e:
+ e.return_value = b""
r.text = u"ü"
assert e.call_count == 0
r.text = u"ä"