[New-bugs-announce] [issue46650] `priority` in `sched.scheduler` is not sufficiently tested
Nikita Sobolev
report at bugs.python.org
Sat Feb 5 10:50:10 EST 2022
New submission from Nikita Sobolev <mail at sobolevn.me>:
Right now there only a single test to ensure `priority` works correctly in `scheduler`: https://github.com/python/cpython/blob/fea7290a0ecee09bbce571d4d10f5881b7ea3485/Lib/test/test_sched.py#L90-L97
It looks like it is not enough. Why?
```
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])
```
This test does not actually test different priorities. It only tests that a direct one works correctly. But, this might be a pure coincidence that numbers match. They are spawned in this particular order.
What if there are equal numbers? Like `[1, 2, 1]`
I propose adding more examples to this test. PR is on its way.
----------
components: Tests
messages: 412577
nosy: sobolevn
priority: normal
severity: normal
status: open
title: `priority` in `sched.scheduler` is not sufficiently tested
type: behavior
versions: Python 3.11
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46650>
_______________________________________
More information about the New-bugs-announce
mailing list