diff options
Diffstat (limited to 'test/mitmproxy/contentviews/test_json.py')
-rw-r--r-- | test/mitmproxy/contentviews/test_json.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/mitmproxy/contentviews/test_json.py b/test/mitmproxy/contentviews/test_json.py new file mode 100644 index 00000000..5e87b570 --- /dev/null +++ b/test/mitmproxy/contentviews/test_json.py @@ -0,0 +1,16 @@ +from mitmproxy.contentviews import json +from . import full_eval + + +def test_pretty_json(): + assert json.pretty_json(b'{"foo": 1}') + assert not json.pretty_json(b"moo") + assert json.pretty_json(b'{"foo" : "\xe4\xb8\x96\xe7\x95\x8c"}') # utf8 with chinese characters + assert not json.pretty_json(b'{"foo" : "\xFF"}') + + +def test_view_json(): + v = full_eval(json.ViewJSON()) + assert v(b"{}") + assert not v(b"{") + assert v(b"[1, 2, 3, 4, 5]") |