Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Event-Loop fixture that does not automatically advance time #95

Open
derekbrokeit opened this issue Sep 10, 2018 · 4 comments

Comments

@derekbrokeit
Copy link

It would be ideal to add an additional clock_event_loop fixture with a custom AbstractEventLoop. Instead, this one would only advance time explicitly similar to the twisted.internet.task.Clock useful for testing twisted reactors. This would allow for tests to advance time and test time-based features to verify that they are correctly running when expected without having to wait for time to progress. If there is a different way to achieve this goal, I would appreciate the advice if I missed something.

derekbrokeit added a commit to derekbrokeit/pytest-asyncio that referenced this issue Sep 10, 2018
@albertodonato
Copy link

#83 seems similar to what you want

@derekbrokeit
Copy link
Author

Thanks @albertodonato , I've been working on this for a bit now and #110 is the most recent set of commits to achieve this behavior in case you are interested.

@derekbrokeit
Copy link
Author

derekbrokeit commented Feb 7, 2019

Looking at your fixture in #83 is very interesting. #110 (and the original #96) takes a different approach, changing the loop class to give all event_loop's the advance_time coroutine, but having it as a stand alone fixture could be a good alternative solution. You would probably want to remove any calls to private loop functions though (e.g. loop._ready)

@altendky
Copy link
Member

altendky commented Feb 6, 2022

Along with the inspiration from Twisted, consider Trio as well. https://pytest-trio.readthedocs.io/en/stable/reference.html#autojump_clock Advancing time automatically even faster than the wall clock is very useful as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants