Skip to content

Commit 46f791d

Browse files
pythongh-90808: add more examples to test_sched.test_priority (pythonGH-31144)
(cherry picked from commit 57463d4) Co-authored-by: Nikita Sobolev <[email protected]>
1 parent e066c6a commit 46f791d

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

Lib/test/test_sched.py

+17-4
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,23 @@ def test_priority(self):
9292
l = []
9393
fun = lambda x: l.append(x)
9494
scheduler = sched.scheduler(time.time, time.sleep)
95-
for priority in [1, 2, 3, 4, 5]:
96-
z = scheduler.enterabs(0.01, priority, fun, (priority,))
97-
scheduler.run()
98-
self.assertEqual(l, [1, 2, 3, 4, 5])
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()
99112

100113
def test_cancel(self):
101114
l = []

0 commit comments

Comments
 (0)