Message52578
Your patch looks good and worked fine.
Wouldn't it be nice to add a test case for this problem to test_pprint.py?
The following is just draft patch to add the test case.
Index: Lib/test/test_pprint.py
===================================================================
--- Lib/test/test_pprint.py (revision 55144)
+++ Lib/test/test_pprint.py (working copy)
@@ -195,7 +195,22 @@
others.should.not.be: like.this}"""
self.assertEqual(DottedPrettyPrinter().pformat(o), exp)
+ 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), str(nested_tuple))
+ self.assertEqual(pprint.pformat(nested_dict), str(nested_dict))
+ self.assertEqual(pprint.pformat(nested_list), str(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)
+
|
|
Date |
User |
Action |
Args |
2007-08-23 15:58:21 | admin | link | issue1713041 messages |
2007-08-23 15:58:21 | admin | create | |
|