[Python-checkins] gh-90808: add more examples to `test_sched.test_priority` (GH-31144)
miss-islington
webhook-mailer at python.org
Tue Sep 20 21:55:19 EDT 2022
https://github.com/python/cpython/commit/9a111a50365aa914be2cd528c3102c91b74879ab
commit: 9a111a50365aa914be2cd528c3102c91b74879ab
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-09-20T18:55:13-07:00
summary:
gh-90808: add more examples to `test_sched.test_priority` (GH-31144)
(cherry picked from commit 57463d43dc4277a1f4d33bd003567e947c937cf5)
Co-authored-by: Nikita Sobolev <mail at sobolevn.me>
files:
M Lib/test/test_sched.py
diff --git a/Lib/test/test_sched.py b/Lib/test/test_sched.py
index 7ae7baae85e..b9c8ea396a4 100644
--- a/Lib/test/test_sched.py
+++ b/Lib/test/test_sched.py
@@ -91,10 +91,23 @@ def test_priority(self):
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 = []
More information about the Python-checkins
mailing list