Commits

Antoine Pitrou  committed 48a9106

Avoid py3k warnings related to sort() of unrelated types.

  • Participants
  • Parent commits f3e2a9d
  • Branches 2.7

Comments (0)

Files changed (1)

File Lib/test/mapping_tests.py

         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
         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)