Skip to content

Commit

Permalink
Sort before comparing dicts in TestChainMap
Browse files Browse the repository at this point in the history
Sort the results of items() of a dict before comparing them.  PyPy
apparently does not produce consistent ordering on .items().

Fixes one of the failures from bug #530
  • Loading branch information
mgorny committed Nov 15, 2019
1 parent 01a1d31 commit 6126997
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tests/test_future/test_backports.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ def test_basics(self):
d['b'] = 20
d['c'] = 30
self.assertEqual(d.maps, [{'b':20, 'c':30}, {'a':1, 'b':2}]) # check internal state
self.assertEqual(d.items(), dict(a=1, b=20, c=30).items()) # check items/iter/getitem
self.assertEqual(sorted(d.items()),
sorted(dict(a=1, b=20, c=30).items())) # check items/iter/getitem
self.assertEqual(len(d), 3) # check len
for key in 'abc': # check contains
self.assertIn(key, d)
Expand All @@ -96,7 +97,8 @@ def test_basics(self):

del d['b'] # unmask a value
self.assertEqual(d.maps, [{'c':30}, {'a':1, 'b':2}]) # check internal state
self.assertEqual(d.items(), dict(a=1, b=2, c=30).items()) # check items/iter/getitem
self.assertEqual(sorted(d.items()),
sorted(dict(a=1, b=2, c=30).items())) # check items/iter/getitem
self.assertEqual(len(d), 3) # check len
for key in 'abc': # check contains
self.assertIn(key, d)
Expand Down

0 comments on commit 6126997

Please sign in to comment.