Add context manager for invoke_later and invoke_when for gui testing
- Dominant language
- Python
- Stars
- 115
- Forks
- 54
- PR merge metrics
- No merged PRs in 30d
Description
I have learned, from a separate project that, three main functions are very useful for GUI testing.
(1) A context manager that schedules a function to be invoked later. The invocation will be canceled when leaving the context
(2) A context manager that schedules a function to be invoked when a condition is fulfilled. The invocation will be canceled when leaving the context
(3) A function that starts the event loop and runs until a condition is fulfilled, with a timeout.
(3) is provided by `EventLoopHelper.event_loop_until_condition` (for Qt only?). (1) and (2) are not provided by pyface as context manager, I had to write my own.
Then in tests, I do this pattern a lot:
```
with call_later(wait=0.1, function=run_something_that_makes_condition_true), \
call_when(condition=condition, function=close_and_exit):
loop_until(condition=lambda: False, timeout=20.0)
```
The main idea about implementing these context managers is that they prevent test interactions: An invocation scheduled in the event loop by one test will never be run in another test.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.