From 23da6e654586bd59af566c6ed5d3e89bc55e8b23 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Mon, 12 May 2008 16:26:52 +0000 Subject: #1713041: fix pprint's handling of maximum depth. --- Lib/test/test_pprint.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'Lib/test/test_pprint.py') 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): -- cgit v1.2.1