Please enable deterministic scheduling in the pytest plugin under Trio
- 主要言語
- Python
- スター
- 2.5k
- フォーク
- 260
- 平均マージ
- 2日 8時間
- マージ済み PR(30日)
- 19
説明
### Things to check first
- [X] I have searched the existing issues and didn't find my feature already requested there
### Feature description
I request a pytest plugin feature to enable deterministic testing, similar to what is done under [pytest-trio](https://github.com/python-trio/pytest-trio). I do not see any easy way to do this for the asyncio backend.
I have made a [feature request in trio](https://github.com/python-trio/trio/issues/2675) to enable keywording of this as a backend feature, which is a far preferable way of implementing the same thing.
### Use case
Deterministic scheduling is very handy in many test scenarios. Trio allows somewhat-deterministic scheduling through monkey-patching its event loop generator to set `_ALLOW_DETERMINISTIC_SCHEDULING` and replacing its random-value generator with a seeded one. Both of which are done by `pytest-trio`, but not by the AnyIO pytest plugin. I say "somewhat-deterministic" because differences in thread timing based on CPU utilization can still introduce stochastic elements, even in fully mocked-up code.
AFAIK, it's not similarly easy to achieve deterministic-ish scheduling with asyncio, although I have seen code that injects additional jobs into the event loop to make a state machine of sorts. One thing that attracted me to AnyIO is to do deterministic (and non-performant) testing with `trio` and then use `asyncio+uvloop` in production.
コントリビューションガイド
評価
この issue はまだ評価されていません。