diff options
Diffstat (limited to 'test/netlib/http/test_message.py')
-rw-r--r-- | test/netlib/http/test_message.py | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/test/netlib/http/test_message.py b/test/netlib/http/test_message.py index 8374f8f6..2bc8824f 100644 --- a/test/netlib/http/test_message.py +++ b/test/netlib/http/test_message.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -from netlib.tutils import tresp -from netlib import http, tutils +from mitmproxy.test import tutils +from netlib import http def _test_passthrough_attr(message, attr): @@ -37,12 +37,12 @@ def _test_decoded_attr(message, attr): class TestMessageData: def test_eq_ne(self): - data = tresp(timestamp_start=42, timestamp_end=42).data - same = tresp(timestamp_start=42, timestamp_end=42).data + data = tutils.tresp(timestamp_start=42, timestamp_end=42).data + same = tutils.tresp(timestamp_start=42, timestamp_end=42).data assert data == same assert not data != same - other = tresp(content=b"foo").data + other = tutils.tresp(content=b"foo").data assert not data == other assert data != other @@ -52,28 +52,28 @@ class TestMessageData: class TestMessage: def test_init(self): - resp = tresp() + resp = tutils.tresp() assert resp.data def test_eq_ne(self): - resp = tresp(timestamp_start=42, timestamp_end=42) - same = tresp(timestamp_start=42, timestamp_end=42) + resp = tutils.tresp(timestamp_start=42, timestamp_end=42) + same = tutils.tresp(timestamp_start=42, timestamp_end=42) assert resp == same assert not resp != same - other = tresp(timestamp_start=0, timestamp_end=0) + other = tutils.tresp(timestamp_start=0, timestamp_end=0) assert not resp == other assert resp != other assert resp != 0 def test_serializable(self): - resp = tresp() + resp = tutils.tresp() resp2 = http.Response.from_state(resp.get_state()) assert resp == resp2 def test_content_length_update(self): - resp = tresp() + resp = tutils.tresp() resp.content = b"foo" assert resp.data.content == b"foo" assert resp.headers["content-length"] == "3" @@ -85,19 +85,19 @@ class TestMessage: assert resp.headers["content-length"] == "0" def test_headers(self): - _test_passthrough_attr(tresp(), "headers") + _test_passthrough_attr(tutils.tresp(), "headers") def test_timestamp_start(self): - _test_passthrough_attr(tresp(), "timestamp_start") + _test_passthrough_attr(tutils.tresp(), "timestamp_start") def test_timestamp_end(self): - _test_passthrough_attr(tresp(), "timestamp_end") + _test_passthrough_attr(tutils.tresp(), "timestamp_end") def test_http_version(self): - _test_decoded_attr(tresp(), "http_version") + _test_decoded_attr(tutils.tresp(), "http_version") def test_replace(self): - r = tresp() + r = tutils.tresp() r.content = b"foofootoo" r.replace(b"foo", "gg") assert r.content == b"ggggtoo" @@ -109,7 +109,7 @@ class TestMessage: class TestMessageContentEncoding: def test_simple(self): - r = tresp() + r = tutils.tresp() assert r.raw_content == b"message" assert "content-encoding" not in r.headers r.encode("gzip") @@ -120,7 +120,7 @@ class TestMessageContentEncoding: assert r.raw_content != b"message" def test_modify(self): - r = tresp() + r = tutils.tresp() assert "content-encoding" not in r.headers r.encode("gzip") @@ -133,7 +133,7 @@ class TestMessageContentEncoding: r.content = u"foo" def test_unknown_ce(self): - r = tresp() + r = tutils.tresp() r.headers["content-encoding"] = "zopfli" r.raw_content = b"foo" with tutils.raises(ValueError): @@ -142,7 +142,7 @@ class TestMessageContentEncoding: assert r.get_content(strict=False) == b"foo" def test_cannot_decode(self): - r = tresp() + r = tutils.tresp() r.encode("gzip") r.raw_content = b"foo" with tutils.raises(ValueError): @@ -160,7 +160,7 @@ class TestMessageContentEncoding: assert "content-encoding" not in r.headers def test_none(self): - r = tresp(content=None) + r = tutils.tresp(content=None) assert r.content is None r.content = b"foo" assert r.content is not None @@ -168,7 +168,7 @@ class TestMessageContentEncoding: assert r.content is None def test_cannot_encode(self): - r = tresp() + r = tutils.tresp() r.encode("gzip") r.content = None assert r.headers["content-encoding"] @@ -187,7 +187,7 @@ class TestMessageContentEncoding: class TestMessageText: def test_simple(self): - r = tresp(content=b'\xfc') + r = tutils.tresp(content=b'\xfc') assert r.raw_content == b"\xfc" assert r.content == b"\xfc" assert r.text == u"ü" @@ -204,12 +204,12 @@ class TestMessageText: assert r.text == u"ü" def test_guess_json(self): - r = tresp(content=b'"\xc3\xbc"') + r = tutils.tresp(content=b'"\xc3\xbc"') r.headers["content-type"] = "application/json" assert r.text == u'"ü"' def test_none(self): - r = tresp(content=None) + r = tutils.tresp(content=None) assert r.text is None r.text = u"foo" assert r.text is not None @@ -217,7 +217,7 @@ class TestMessageText: assert r.text is None def test_modify(self): - r = tresp() + r = tutils.tresp() r.text = u"ü" assert r.raw_content == b"\xfc" @@ -228,7 +228,7 @@ class TestMessageText: assert r.headers["content-length"] == "2" def test_unknown_ce(self): - r = tresp() + r = tutils.tresp() r.headers["content-type"] = "text/html; charset=wtf" r.raw_content = b"foo" with tutils.raises(ValueError): @@ -236,7 +236,7 @@ class TestMessageText: assert r.get_text(strict=False) == u"foo" def test_cannot_decode(self): - r = tresp() + r = tutils.tresp() r.headers["content-type"] = "text/html; charset=utf8" r.raw_content = b"\xFF" with tutils.raises(ValueError): @@ -245,7 +245,7 @@ class TestMessageText: assert r.get_text(strict=False) == '\udcff' def test_cannot_encode(self): - r = tresp() + r = tutils.tresp() r.content = None assert "content-type" not in r.headers assert r.raw_content is None |