From a6b3551934e2b8768177d6831ca08f97f5bdae44 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Mon, 4 Jul 2016 13:58:09 -0700 Subject: raise ValueError if content-encoding is invalid --- test/netlib/http/test_message.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'test') 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"ä" -- cgit v1.2.3