summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pprint.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-10-02 08:56:18 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-10-02 08:56:18 (GMT)
commit7c411a40413d9525aeb6114d71be3e012dbf81f5 (patch)
tree240af349b039b0efd5c52903bff110748815280a /Lib/test/test_pprint.py
parent092bd388ced26650cf0a5a4838a87f7ca8a9ea97 (diff)
downloadcpython-7c411a40413d9525aeb6114d71be3e012dbf81f5.zip
cpython-7c411a40413d9525aeb6114d71be3e012dbf81f5.tar.gz
cpython-7c411a40413d9525aeb6114d71be3e012dbf81f5.tar.bz2
Issue #19132: The pprint module now supports compact mode.
Diffstat (limited to 'Lib/test/test_pprint.py')
-rw-r--r--Lib/test/test_pprint.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_pprint.py b/Lib/test/test_pprint.py
index 5a2050f..3d364c4 100644
--- a/Lib/test/test_pprint.py
+++ b/Lib/test/test_pprint.py
@@ -568,6 +568,18 @@ frozenset2({0,
formatted = pprint.pformat(special, width=width)
self.assertEqual(eval("(" + formatted + ")"), special)
+ def test_compact(self):
+ o = ([list(range(i * i)) for i in range(5)] +
+ [list(range(i)) for i in range(6)])
+ expected = """\
+[[], [0], [0, 1, 2, 3],
+ [0, 1, 2, 3, 4, 5, 6, 7, 8],
+ [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
+ 14, 15],
+ [], [0], [0, 1], [0, 1, 2], [0, 1, 2, 3],
+ [0, 1, 2, 3, 4]]"""
+ self.assertEqual(pprint.pformat(o, width=48, compact=True), expected)
+
class DottedPrettyPrinter(pprint.PrettyPrinter):