-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide message of expected exception when timeout happens #12
Comments
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... |
Well, I'd like to perform assert until it succeeds or timeout happens. def assertion()
assert window.url() == 'some_string'
wait(assertion, timeout_seconds=10, expected_exceptions=AssertionError) 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:
|
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? |
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 |
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. |
I think it will be a specific subclass of a new class which |
The following appears to work fine for me: def assertion()
assert window.url() == 'some_string'
return True
wait(assertion, timeout_seconds=10, expected_exceptions=AssertionError) together with a code change like abotalov@0d43a52 appears to work. |
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.
The text was updated successfully, but these errors were encountered: