We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
test_sched.test_priority
1 parent aced809 commit 9a111a5Copy full SHA for 9a111a5
Lib/test/test_sched.py
@@ -91,10 +91,23 @@ def test_priority(self):
91
l = []
92
fun = lambda x: l.append(x)
93
scheduler = sched.scheduler(time.time, time.sleep)
94
- for priority in [1, 2, 3, 4, 5]:
95
- z = scheduler.enterabs(0.01, priority, fun, (priority,))
96
- scheduler.run()
97
- 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]),
98
+ ([2, 5, 3, 1, 4], [1, 2, 3, 4, 5]),
99
+ ([1, 2, 3, 2, 1], [1, 1, 2, 2, 3]),
100
+ ]
101
+ for priorities, expected in cases:
102
+ with self.subTest(priorities=priorities, expected=expected):
103
+ for priority in priorities:
104
+ scheduler.enterabs(0.01, priority, fun, (priority,))
105
+ scheduler.run()
106
+ self.assertEqual(l, expected)
107
108
+ # Cleanup:
109
+ self.assertTrue(scheduler.empty())
110
+ l.clear()
111
112
def test_cancel(self):
113
0 commit comments