MCPcopy Index your code
hub / github.com/python/cpython / test_cmp_to_key

Method test_cmp_to_key

Lib/test/test_functools.py:1156–1170  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1154class TestCmpToKey:
1155
1156 def test_cmp_to_key(self):
1157 def cmp1(x, y):
1158 return (x > y) - (x < y)
1159 key = self.cmp_to_key(cmp1)
1160 self.assertEqual(key(3), key(3))
1161 self.assertGreater(key(3), key(1))
1162 self.assertGreaterEqual(key(3), key(3))
1163
1164 def cmp2(x, y):
1165 return int(x) - int(y)
1166 key = self.cmp_to_key(cmp2)
1167 self.assertEqual(key(4.0), key('4'))
1168 self.assertLess(key(2), key('35'))
1169 self.assertLessEqual(key(2), key('35'))
1170 self.assertNotEqual(key(2), key('35'))
1171
1172 def test_cmp_to_key_arguments(self):
1173 def cmp1(x, y):

Callers

nothing calls this directly

Calls 6

assertGreaterMethod · 0.80
assertGreaterEqualMethod · 0.80
assertLessEqualMethod · 0.80
assertNotEqualMethod · 0.80
assertEqualMethod · 0.45
assertLessMethod · 0.45

Tested by

no test coverage detected