This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author josm
Recipients
Date 2007-05-10.11:56:51
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
I agree. The code and the doc should be consistent.

New test would be

Index: Lib/test/test_pprint.py
===================================================================
--- Lib/test/test_pprint.py	(revision 55223)
+++ Lib/test/test_pprint.py	(working copy)
@@ -195,7 +195,27 @@
  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), repr(nested_tuple))
+        self.assertEqual(pprint.pformat(nested_dict), repr(nested_dict))
+        self.assertEqual(pprint.pformat(nested_list), repr(nested_list))
+
+        result_tuple = {'lv1': '(...)',
+                        'lv2': '(1, (...))'}
+        result_dict = {'lv1': '{...}',
+                       'lv2': '{1: {...}}'}
+        result_list = {'lv1': '[...]',
+                       'lv2': '[1, [...]]'}
+        for i in [1, 2]:
+            key = 'lv' + `i`
+            self.assertEqual(pprint.pformat(nested_tuple, depth=i), result_tuple[key])
+            self.assertEqual(pprint.pformat(nested_dict, depth=i), result_dict[key])
+            self.assertEqual(pprint.pformat(nested_list, depth=i), result_list[key])
+
 class DottedPrettyPrinter(pprint.PrettyPrinter):
 
     def format(self, object, context, maxlevels, level):
History
Date User Action Args
2007-08-23 15:58:21adminlinkissue1713041 messages
2007-08-23 15:58:21admincreate