You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Provide message of expected exception when timeout happens #12
Currently if both timeout_seconds and expected_exception are used, only information that timeout expired is printed.
It would be good to add exception message of expected exception to TimeoutExpired message.
Can you please provide an example (not necessarily working) code snippet and what you expect to happen with it that currently does not happen? I'm not sure I'm following correctly...
expected_exceptions in this case means "exceptions that are allowed to happen while polling", so they are ignored... I don't see the logic behind raising them on timeout....
The use case is described above. Could you propose a better way to do it?
Yes, these exceptions are allowed to happen until timeout. But once timeout happened, the message is useful for debugging.
Ah, I just got that a solution I proposed before wouldn't fully work. As successful assertion returns None rather than True. But it could be worked around by returning True from a func.
Will the mechanism that you wrote about work by raising a specific exception that is catched in wait?
together with a code change like abotalov@0d43a52 appears to work.
The code change only outlines idea - it would be better to pass a message as a third parameter and to build a better message in TimeoutExpired.
Activity
vmalloc commentedon Sep 27, 2018
Can you please provide an example (not necessarily working) code snippet and what you expect to happen with it that currently does not happen? I'm not sure I'm following correctly...
abotalov commentedon Sep 27, 2018
Well, I'd like to perform assert until it succeeds or timeout happens.
Similar feature exists in pytest-qt (https://pytest-qt.readthedocs.io/en/latest/wait_until.html). There, if timeout happens, an expected exception is raised instead of TimeoutError (https://github.com/pytest-dev/pytest-qt/blob/master/pytestqt/qtbot.py#L520). The benefit is that a user sees a message that helps to understand why timeout has happened.
waiting library may however still raise TimeoutExpired but a message can be improved to include a message of happened expected exception.
Currently I see only something like:
vmalloc commentedon Sep 27, 2018
expected_exceptions in this case means "exceptions that are allowed to happen while polling", so they are ignored... I don't see the logic behind raising them on timeout....
abotalov commentedon Sep 27, 2018
The use case is described above. Could you propose a better way to do it?
Yes, these exceptions are allowed to happen until timeout. But once timeout happened, the message is useful for debugging.
vmalloc commentedon Sep 27, 2018
I see...
What if you had some adapter to achieve this, like:
Then in this use case I can make the "default" message formatting consider this object type and print the last exception encountered on it
abotalov commentedon Sep 27, 2018
Ah, I just got that a solution I proposed before wouldn't fully work. As successful assertion returns None rather than True. But it could be worked around by returning True from a func.
Will the mechanism that you wrote about work by raising a specific exception that is catched in
wait?vmalloc commentedon Sep 27, 2018
I think it will be a specific subclass of a new class which
waitingrecognized, and which can be queried for the exact reason for not succeedingabotalov commentedon Sep 27, 2018
The following appears to work fine for me:
together with a code change like abotalov@0d43a52 appears to work.
The code change only outlines idea - it would be better to pass a message as a third parameter and to build a better message in
TimeoutExpired.