textual icon indicating copy to clipboard operation
textual copied to clipboard

Use time_machine for integration tests

Open willmcgugan opened this issue 2 years ago • 1 comments

We should use the time_machine library to run integration tests involving animation or anything time sensitive. This will allow us to write deterministic tests.

There is a test of animation that we should convert to this.

willmcgugan avatar May 11 '22 14:05 willmcgugan

As per #507 it turns out that we might not need this. time_machine is great for a lot of use cases, but it's probably not the approach to take in the case of Textual. That's because we not only have to mock the passage of time in the animator as a difference between 2 timestamps (which is where time_machine would shine), but also when we use await asyncio.sleep() (for which time_machine cannot help us).

To be confirmed in the longer term, but it seems that the approach we opted for in #507 (a centralised clock and a centralised set of functions to sleep across the codebase, plus a TestApp that mocks them and keeps their sense of passing time in sync during the integration tests) does the job :slightly_smiling_face: :crossed_fingers:

olivierphi avatar Jun 24 '22 09:06 olivierphi

https://github.com/Textualize/textual/wiki/Sorry-we-closed-your-issue

willmcgugan avatar Oct 25 '22 09:10 willmcgugan

Did we solve your problem?

Glad we could help!

github-actions[bot] avatar Oct 25 '22 09:10 github-actions[bot]