diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2016-06-08 09:19:25 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2016-06-08 09:19:25 +1200 |
commit | db11fe0087776c2bf5d95f5aeb751c6c35d67f4b (patch) | |
tree | 1aab054770dee86506a1897093dde2d35489a0de /test | |
parent | ba466dbb358eba223c49fbe602a667aa1a3c7459 (diff) | |
parent | eb680e7764ec902518bc66e4d5c7667326ed5811 (diff) | |
download | mitmproxy-db11fe0087776c2bf5d95f5aeb751c6c35d67f4b.tar.gz mitmproxy-db11fe0087776c2bf5d95f5aeb751c6c35d67f4b.tar.bz2 mitmproxy-db11fe0087776c2bf5d95f5aeb751c6c35d67f4b.zip |
Merge branch 'master' into beautiful-json
Diffstat (limited to 'test')
-rw-r--r-- | test/netlib/test_strutils.py | 24 | ||||
-rw-r--r-- | test/pathod/test_language_writer.py | 2 |
2 files changed, 24 insertions, 2 deletions
diff --git a/test/netlib/test_strutils.py b/test/netlib/test_strutils.py index 734265c4..84a0dded 100644 --- a/test/netlib/test_strutils.py +++ b/test/netlib/test_strutils.py @@ -1,6 +1,18 @@ # coding=utf-8 +import six -from netlib import strutils +from netlib import strutils, tutils + + +def test_native(): + with tutils.raises(TypeError): + strutils.native(42) + if six.PY2: + assert strutils.native(u"foo") == b"foo" + assert strutils.native(b"foo") == b"foo" + else: + assert strutils.native(u"foo") == u"foo" + assert strutils.native(b"foo") == u"foo" def test_clean_bin(): @@ -29,6 +41,9 @@ def test_bytes_to_escaped_str(): assert strutils.bytes_to_escaped_str(b"'") == r"\'" assert strutils.bytes_to_escaped_str(b'"') == r'"' + with tutils.raises(ValueError): + strutils.bytes_to_escaped_str(u"such unicode") + def test_escaped_str_to_bytes(): assert strutils.escaped_str_to_bytes("foo") == b"foo" @@ -39,6 +54,13 @@ def test_escaped_str_to_bytes(): assert strutils.escaped_str_to_bytes(u"&!?=\\\\)") == br"&!?=\)" assert strutils.escaped_str_to_bytes(u"ΓΌ") == b'\xc3\xbc' + if six.PY2: + with tutils.raises(ValueError): + strutils.escaped_str_to_bytes(42) + else: + with tutils.raises(ValueError): + strutils.escaped_str_to_bytes(b"very byte") + def test_isBin(): assert not strutils.isBin("testing\n\r") diff --git a/test/pathod/test_language_writer.py b/test/pathod/test_language_writer.py index c02f66f3..e857e084 100644 --- a/test/pathod/test_language_writer.py +++ b/test/pathod/test_language_writer.py @@ -87,4 +87,4 @@ def test_write_values_after(): s = BytesIO() r = next(language.parse_pathod("400:ia,'xx'")) language.serve(r, s, {}) - assert s.getvalue().endswith('xx') + assert s.getvalue().endswith(b'xx') |