textual
textual copied to clipboard
Use time_machine for integration tests
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.
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:
https://github.com/Textualize/textual/wiki/Sorry-we-closed-your-issue
Did we solve your problem?
Glad we could help!