mirror of
https://github.com/python/cpython.git
synced 2024-11-21 21:09:37 +01:00
gh-90808: add more examples to test_sched.test_priority
(#31144)
This commit is contained in:
parent
58882640d6
commit
57463d43dc
@ -92,10 +92,23 @@ class TestCase(unittest.TestCase):
|
||||
l = []
|
||||
fun = lambda x: l.append(x)
|
||||
scheduler = sched.scheduler(time.time, time.sleep)
|
||||
for priority in [1, 2, 3, 4, 5]:
|
||||
z = scheduler.enterabs(0.01, priority, fun, (priority,))
|
||||
scheduler.run()
|
||||
self.assertEqual(l, [1, 2, 3, 4, 5])
|
||||
|
||||
cases = [
|
||||
([1, 2, 3, 4, 5], [1, 2, 3, 4, 5]),
|
||||
([5, 4, 3, 2, 1], [1, 2, 3, 4, 5]),
|
||||
([2, 5, 3, 1, 4], [1, 2, 3, 4, 5]),
|
||||
([1, 2, 3, 2, 1], [1, 1, 2, 2, 3]),
|
||||
]
|
||||
for priorities, expected in cases:
|
||||
with self.subTest(priorities=priorities, expected=expected):
|
||||
for priority in priorities:
|
||||
scheduler.enterabs(0.01, priority, fun, (priority,))
|
||||
scheduler.run()
|
||||
self.assertEqual(l, expected)
|
||||
|
||||
# Cleanup:
|
||||
self.assertTrue(scheduler.empty())
|
||||
l.clear()
|
||||
|
||||
def test_cancel(self):
|
||||
l = []
|
||||
|
Loading…
Reference in New Issue
Block a user