summaryrefslogtreecommitdiff
path: root/Lib/test/test_pprint.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-05-12 16:26:52 +0000
committerGeorg Brandl <georg@python.org>2008-05-12 16:26:52 +0000
commit23da6e654586bd59af566c6ed5d3e89bc55e8b23 (patch)
treee5e5f089a061e30920217a4f61f4e16827f372c2 /Lib/test/test_pprint.py
parent103f19d286d7b0a80bd83031d8fd1c0af31dfd9e (diff)
downloadcpython-git-23da6e654586bd59af566c6ed5d3e89bc55e8b23.tar.gz
#1713041: fix pprint's handling of maximum depth.
Diffstat (limited to 'Lib/test/test_pprint.py')
-rw-r--r--Lib/test/test_pprint.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_pprint.py b/Lib/test/test_pprint.py
index 83c772b5b0..4d7a3ed147 100644
--- a/Lib/test/test_pprint.py
+++ b/Lib/test/test_pprint.py
@@ -387,6 +387,21 @@ class QueryTestCase(unittest.TestCase):
cubo = test.test_set.linegraph(cube)
self.assertEqual(pprint.pformat(cubo), cubo_repr_tgt)
+ def test_depth(self):
+ nested_tuple = (1, (2, (3, (4, (5, 6)))))
+ nested_dict = {1: {2: {3: {4: {5: {6: 6}}}}}}
+ nested_list = [1, [2, [3, [4, [5, [6, []]]]]]]
+ self.assertEqual(pprint.pformat(nested_tuple), repr(nested_tuple))
+ self.assertEqual(pprint.pformat(nested_dict), repr(nested_dict))
+ self.assertEqual(pprint.pformat(nested_list), repr(nested_list))
+
+ lv1_tuple = '(1, (...))'
+ lv1_dict = '{1: {...}}'
+ lv1_list = '[1, [...]]'
+ self.assertEqual(pprint.pformat(nested_tuple, depth=1), lv1_tuple)
+ self.assertEqual(pprint.pformat(nested_dict, depth=1), lv1_dict)
+ self.assertEqual(pprint.pformat(nested_list, depth=1), lv1_list)
+
class DottedPrettyPrinter(pprint.PrettyPrinter):