mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
#1713041: fix pprint's handling of maximum depth.
This commit is contained in:
parent
103f19d286
commit
23da6e6545
4 changed files with 26 additions and 6 deletions
|
|
@ -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):
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue