We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
test_sched.test_priority
1 parent e066c6a commit 46f791dCopy full SHA for 46f791d
Lib/test/test_sched.py
@@ -92,10 +92,23 @@ def test_priority(self):
92
l = []
93
fun = lambda x: l.append(x)
94
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])
+
+ cases = [
+ ([1, 2, 3, 4, 5], [1, 2, 3, 4, 5]),
+ ([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
0 commit comments