MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_cmp_to_key

Method test_cmp_to_key

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

Source from the content-addressed store, hash-verified

1090class TestCmpToKey:
1091
1092 def test_cmp_to_key(self):
1093 def cmp1(x, y):
1094 return (x > y) - (x < y)
1095 key = self.cmp_to_key(cmp1)
1096 self.assertEqual(key(3), key(3))
1097 self.assertGreater(key(3), key(1))
1098 self.assertGreaterEqual(key(3), key(3))
1099
1100 def cmp2(x, y):
1101 return int(x) - int(y)
1102 key = self.cmp_to_key(cmp2)
1103 self.assertEqual(key(4.0), key('4'))
1104 self.assertLess(key(2), key('35'))
1105 self.assertLessEqual(key(2), key('35'))
1106 self.assertNotEqual(key(2), key('35'))
1107
1108 def test_cmp_to_key_arguments(self):
1109 def cmp1(x, y):

Callers 1

test_cmp_to_keyMethod · 0.45

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