Skip to content

Commit 530e2fc

Browse files
committed
test_wait.py: fix tests testing exception
In pytest raises() returns an info object whose `value` attribute contains the actual exception caught. Converting to string used to work but currently it returns a string which does not contain the exception text, so it is better to check for the actual exception object instead.
1 parent b107c6f commit 530e2fc

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

tests/test_wait.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def make_unexpected_request_and_wait() -> None:
3030
requests.get(httpserver.url_for("/foobaz"))
3131
assert not waiting.result
3232
no_handler_text = 'No handler found for request'
33-
assert no_handler_text in str(error)
33+
assert no_handler_text in str(error.value)
3434

3535
make_unexpected_request_and_wait()
3636

@@ -49,7 +49,7 @@ def test_wait_timeout(httpserver: HTTPServer):
4949
assert not waiting.result
5050
waiting_time_error = 0.1
5151
assert waiting.elapsed_time == approx(waiting_timeout, abs=waiting_time_error)
52-
assert 'Wait timeout occurred, but some handlers left' in str(error)
52+
assert 'Wait timeout occurred, but some handlers left' in str(error.value)
5353

5454

5555
def test_wait_raise_assertion_false(httpserver: HTTPServer):

0 commit comments

Comments
 (0)