Eventually matcher should catch exceptions on the callable
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Autopilot |
Triaged
|
High
|
Unassigned |
Bug Description
With the current implementation of eventually, if the callable passed as the first argument raises an exception, it will be propagated and the assertion will fail.
I was expecting eventually to catch this exception and keep retrying until it times out. And just at this moment raise the exception.
This is the statement I would like to use:
self.assertThat(
get_last_
As a workaround, I had to wrap it in a function that catches the exception and returns None. This doesn't seem correct, because then I can't test for cases when the parameter passed to the fake service is None.
tags: | added: ap-perf |
tags: | removed: ap-perf |
Hi,
I agree with your problem description, but not with the proposed solution.
The issue here is that Eventually takes callables, and calls them. This is inconsistent with the Matcher API, and introduces other problems as well (for example, you cannot use Eventually and 'raises' matchers together).
I'd rather solve this by deprecating the ability to pass a naked callable to Eventually, and instead encourage people to use the AfterProcessing matcher, or soemthing similar. You could conceptially do:
self.assertThat(
fake_url_ dispatcher. get_last_ dispatch_ url_call_ parameter,
AfterProce ssing(StripExce ption, Equals( 'settings: ///system/ online- accounts' ))
Eventually(
)
)
Or something similar.