enthought / enthought/traitsui
Can traitsui.testing._exception_handling.reraise_exceptions be made public?
- Dominant language
- Python
- Stars
- 306
- Forks
- 99
- PR merge metrics
- No merged PRs in 30d
Description
I have a test where I want to catch exceptions raised on the UI thread, but without actually making a ui.
I had errors being logged but my test passing for a while. I tried `{push/pop}_exception_handler` from both `traits.api` and `traits.observation.api` with `reraise_exceptions` set to true as in the trackback it looked as though the error started in a change handler. This did not resolve the issue though. The test was testing a notification sent through the UI dispatch handler and the event loop needs to run to ensure it gets delivered (learned this through an old slack discussion). So I used pyface GUITestAssistant to drive the event loop (bot not UITester which already uses `reraise_exceptions` under the hood)
I end up with a test that looks like:
```
# a bit of a smell importing from private module
from traitsui.testing._exception_handling import reraise_exceptions
# wire up thing to listen for event and then
# perform various assertions that event looks good
with reraise_exceptions():
with self.event_loop():
# do thing that sends event
```
With this I end up seeing errors cause my test to fail rather than just being logged.
I suspect this was originally in a private module as it was assumed to be hidden behind UITester, but it feels like it could be useful more generally with GuiTestAssistant from pyface in situations where you want to run the ui event loop without firing up a particular ui (e.g. with `with UITester().create_ui(view) as ui: ...`)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.