diff options
author | Nikita Sobolev <mail@sobolevn.me> | 2022-09-21 01:34:13 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-21 01:34:13 (GMT) |
commit | 57463d43dc4277a1f4d33bd003567e947c937cf5 (patch) | |
tree | 46f9c81938856df659650e20a75f08eb633fb855 | |
parent | 58882640d631b0be0d81156928de97c2b3556f45 (diff) | |
download | cpython-57463d43dc4277a1f4d33bd003567e947c937cf5.zip cpython-57463d43dc4277a1f4d33bd003567e947c937cf5.tar.gz cpython-57463d43dc4277a1f4d33bd003567e947c937cf5.tar.bz2 |
gh-90808: add more examples to `test_sched.test_priority` (#31144)
-rw-r--r-- | Lib/test/test_sched.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/Lib/test/test_sched.py b/Lib/test/test_sched.py index 32cc810..eb52ac7 100644 --- a/Lib/test/test_sched.py +++ b/Lib/test/test_sched.py @@ -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 = [] |