From 93291534b717390c06aa7ba51361cf5be51349ad Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Wed, 22 Feb 2012 00:28:46 +0100 Subject: Avoid py3k warnings related to sort() of unrelated types. --- Lib/test/mapping_tests.py | 10 +++++++--- 1 file 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) -- cgit v0.12