diff options
author | Maximilian Hils <git@maximilianhils.com> | 2017-01-06 00:31:06 +0100 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2017-01-07 23:08:50 +0100 |
commit | 042261266f5b901b2b0745fd108c9a92525e9087 (patch) | |
tree | 534f27bcad822a6e5ad5951875a4a1a2aba8bb93 /test | |
parent | af194918cf862294216e67555b2a5e4ab9f93b08 (diff) | |
download | mitmproxy-042261266f5b901b2b0745fd108c9a92525e9087.tar.gz mitmproxy-042261266f5b901b2b0745fd108c9a92525e9087.tar.bz2 mitmproxy-042261266f5b901b2b0745fd108c9a92525e9087.zip |
minor encoding fixes
- native() -> always_str()
The old function name does not make sense on Python 3 only.
- Inline utility functions in message.py.
Diffstat (limited to 'test')
-rw-r--r-- | test/mitmproxy/net/http/test_response.py | 15 | ||||
-rw-r--r-- | test/mitmproxy/utils/test_strutils.py | 9 |
2 files changed, 19 insertions, 5 deletions
diff --git a/test/mitmproxy/net/http/test_response.py b/test/mitmproxy/net/http/test_response.py index 239fb6ef..eae957a8 100644 --- a/test/mitmproxy/net/http/test_response.py +++ b/test/mitmproxy/net/http/test_response.py @@ -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/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(): |