Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6e571d6

Browse files
committed
Fix test_pprint random dict ordering.
1 parent d6da90f commit 6e571d6

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

Lib/test/test_pprint.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,9 @@ def test_sort_unorderable_values(self):
467467
'{1: 0, ' + repr(Unorderable) +': 0}')
468468

469469
# Issue 14998: TypeError on tuples with NoneTypes as dict keys.
470-
self.assertEqual(pprint.pformat({(1,): 0, (None,): 0}),
471-
'{(1,): 0, (None,): 0}')
470+
keys = [(1,), (None,)]
471+
self.assertEqual(pprint.pformat(dict.fromkeys(keys, 0)),
472+
'{%r: 0, %r: 0}' % tuple(sorted(keys, key=id)))
472473

473474

474475
class DottedPrettyPrinter(pprint.PrettyPrinter):

0 commit comments

Comments
 (0)