From 18d4c3a9e96fad9683b87e2202a078722291a72b Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Thu, 30 Jun 2011 13:27:27 +1200 Subject: JSON pretty-printing. Also rename the display modes ("pretty" instead of "indent"), and expand the built-in documentation. --- test/test_utils.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'test/test_utils.py') diff --git a/test/test_utils.py b/test/test_utils.py index 6aefd403..b64db918 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -1,4 +1,4 @@ -import textwrap, cStringIO, os, time, re +import textwrap, cStringIO, os, time, re, json import libpry from libmproxy import utils @@ -283,6 +283,13 @@ class upretty_xmlish(libpry.AutoTree): assert utils.pretty_xmlish(s) == ["gobbledygook"] +class upretty_json(libpry.AutoTree): + def test_one(self): + s = json.dumps({"foo": 1}) + assert utils.pretty_json(s) + assert not utils.pretty_json("moo") + + class udummy_ca(libpry.AutoTree): def test_all(self): d = self.tmpdir() @@ -368,6 +375,7 @@ tests = [ uHeaders(), uData(), upretty_xmlish(), + upretty_json(), udummy_ca(), udummy_cert(), uLRUCache(), -- cgit v1.2.3