diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/mitmproxy/net/http/test_response.py | 17 | ||||
-rw-r--r-- | test/mitmproxy/test_web_app.py | 4 | ||||
-rw-r--r-- | test/mitmproxy/utils/test_strutils.py | 9 |
3 files changed, 22 insertions, 8 deletions
diff --git a/test/mitmproxy/net/http/test_response.py b/test/mitmproxy/net/http/test_response.py index 239fb6ef..ad250387 100644 --- a/test/mitmproxy/net/http/test_response.py +++ b/test/mitmproxy/net/http/test_response.py @@ -6,7 +6,7 @@ from mitmproxy.net.http import Headers from mitmproxy.net.http import Response from mitmproxy.net.http.cookies import CookieAttrs from mitmproxy.test.tutils import raises, tresp -from .test_message import _test_passthrough_attr, _test_decoded_attr +from .test_message import _test_passthrough_attr class TestResponseData: @@ -55,7 +55,20 @@ class TestResponseCore: _test_passthrough_attr(tresp(), "status_code") def test_reason(self): - _test_decoded_attr(tresp(), "reason") + resp = tresp() + assert resp.reason == "OK" + + resp.reason = "ABC" + assert resp.data.reason == b"ABC" + + resp.reason = b"DEF" + assert resp.data.reason == b"DEF" + + resp.reason = None + assert resp.data.reason is None + + resp.data.reason = b'cr\xe9e' + assert resp.reason == "crée" class TestResponseUtils: diff --git a/test/mitmproxy/test_web_app.py b/test/mitmproxy/test_web_app.py index 61cf6993..7da5e4e9 100644 --- a/test/mitmproxy/test_web_app.py +++ b/test/mitmproxy/test_web_app.py @@ -129,7 +129,7 @@ class TestApp(tornado.testing.AsyncHTTPTestCase): "content": "req", }, "response": { - "msg": "Not Found", + "msg": "Non-Authorisé", "code": 404, "headers": [("bar", "baz")], "content": "resp", @@ -140,7 +140,7 @@ class TestApp(tornado.testing.AsyncHTTPTestCase): assert f.request.port == 123 assert f.request.headers["foo"] == "bar" assert f.request.text == "req" - assert f.response.msg == "Not Found" + assert f.response.msg == "Non-Authorisé" assert f.response.status_code == 404 assert f.response.headers["bar"] == "baz" assert f.response.text == "resp" diff --git a/test/mitmproxy/utils/test_strutils.py b/test/mitmproxy/utils/test_strutils.py index 84281c6b..1372d31f 100644 --- a/test/mitmproxy/utils/test_strutils.py +++ b/test/mitmproxy/utils/test_strutils.py @@ -11,11 +11,12 @@ def test_always_bytes(): strutils.always_bytes(42, "ascii") -def test_native(): +def test_always_str(): with tutils.raises(TypeError): - strutils.native(42) - assert strutils.native(u"foo") == u"foo" - assert strutils.native(b"foo") == u"foo" + strutils.always_str(42) + assert strutils.always_str("foo") == "foo" + assert strutils.always_str(b"foo") == "foo" + assert strutils.always_str(None) is None def test_escape_control_characters(): |