diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-02-21 23:28:46 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-02-21 23:28:46 (GMT) |
commit | 93291534b717390c06aa7ba51361cf5be51349ad (patch) | |
tree | 735a99afeeb083c91d50a2f5e622c583765f4fee | |
parent | 66e565ee4825541e7bd9e544dcf8cefa999907f7 (diff) | |
download | cpython-93291534b717390c06aa7ba51361cf5be51349ad.zip cpython-93291534b717390c06aa7ba51361cf5be51349ad.tar.gz cpython-93291534b717390c06aa7ba51361cf5be51349ad.tar.bz2 |
Avoid py3k warnings related to sort() of unrelated types.
-rw-r--r-- | Lib/test/mapping_tests.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/test/mapping_tests.py b/Lib/test/mapping_tests.py index 49f6379..f43750b 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) |