diff --git a/Lib/test/mapping_tests.py b/Lib/test/mapping_tests.py index 49f6379f82a..f43750bb83f 100644 --- a/Lib/test/mapping_tests.py +++ b/Lib/test/mapping_tests.py @@ -209,8 +209,12 @@ class BasicTestMappingProtocol(unittest.TestCase): d.update(SimpleUserDict()) i1 = d.items() i2 = self.reference.items() - i1.sort() - i2.sort() + + def safe_sort_key(kv): + k, v = kv + return id(type(k)), id(type(v)), k, v + i1.sort(key=safe_sort_key) + i2.sort(key=safe_sort_key) self.assertEqual(i1, i2) class Exc(Exception): pass @@ -343,7 +347,7 @@ class TestMappingProtocol(BasicTestMappingProtocol): self.assertTrue(not d.has_key('a')) d = self._full_mapping({'a': 1, 'b': 2}) k = d.keys() - k.sort() + k.sort(key=lambda k: (id(type(k)), k)) self.assertEqual(k, ['a', 'b']) self.assertRaises(TypeError, d.has_key)