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

Method test_colors

Lib/test/test_bisect.py:401–409  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

399 self.assertEqual(result, ['F', 'A', 'C', 'C', 'B', 'A', 'A'])
400
401 def test_colors(self):
402 data = [('red', 5), ('blue', 1), ('yellow', 8), ('black', 0)]
403 data.sort(key=lambda r: r[1])
404 keys = [r[1] for r in data]
405 bisect_left = self.module.bisect_left
406 self.assertEqual(data[bisect_left(keys, 0)], ('black', 0))
407 self.assertEqual(data[bisect_left(keys, 1)], ('blue', 1))
408 self.assertEqual(data[bisect_left(keys, 5)], ('red', 5))
409 self.assertEqual(data[bisect_left(keys, 8)], ('yellow', 8))
410
411class TestDocExamplePython(TestDocExample, unittest.TestCase):
412 module = py_bisect

Callers

nothing calls this directly

Calls 3

bisect_leftFunction · 0.85
sortMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected