]> granicus.if.org Git - python/commitdiff
Fix test_pprint random dict ordering.
authorFlorent Xicluna <florent.xicluna@gmail.com>
Sat, 21 Jul 2012 10:44:20 +0000 (12:44 +0200)
committerFlorent Xicluna <florent.xicluna@gmail.com>
Sat, 21 Jul 2012 10:44:20 +0000 (12:44 +0200)
Lib/test/test_pprint.py

index 7daf4a7b60c157a183ef2261eca58aebc2d8864a..0c93d0e59b701d848712fdb2b95198f70c70b207 100644 (file)
@@ -467,8 +467,9 @@ class QueryTestCase(unittest.TestCase):
                          '{1: 0, ' + repr(Unorderable) +': 0}')
 
         # Issue 14998: TypeError on tuples with NoneTypes as dict keys.
-        self.assertEqual(pprint.pformat({(1,): 0, (None,): 0}),
-                         '{(1,): 0, (None,): 0}')
+        keys = [(1,), (None,)]
+        self.assertEqual(pprint.pformat(dict.fromkeys(keys, 0)),
+                         '{%r: 0, %r: 0}' % tuple(sorted(keys, key=id)))
 
 
 class DottedPrettyPrinter(pprint.PrettyPrinter):