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

Method test_priority

Lib/test/test_sched.py:91–111  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

89 self.assertEqual(timer.time(), 5)
90
91 def test_priority(self):
92 l = []
93 fun = lambda x: l.append(x)
94 scheduler = sched.scheduler(time.time, time.sleep)
95
96 cases = [
97 ([1, 2, 3, 4, 5], [1, 2, 3, 4, 5]),
98 ([5, 4, 3, 2, 1], [1, 2, 3, 4, 5]),
99 ([2, 5, 3, 1, 4], [1, 2, 3, 4, 5]),
100 ([1, 2, 3, 2, 1], [1, 1, 2, 2, 3]),
101 ]
102 for priorities, expected in cases:
103 with self.subTest(priorities=priorities, expected=expected):
104 for priority in priorities:
105 scheduler.enterabs(0.01, priority, fun, (priority,))
106 scheduler.run()
107 self.assertEqual(l, expected)
108
109 # Cleanup:
110 self.assertTrue(scheduler.empty())
111 l.clear()
112
113 def test_cancel(self):
114 l = []

Callers

nothing calls this directly

Calls 8

subTestMethod · 0.95
assertEqualMethod · 0.95
assertTrueMethod · 0.95
enterabsMethod · 0.80
appendMethod · 0.45
runMethod · 0.45
emptyMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected