diff --git a/tests/integration/test_webserver.py b/tests/integration/test_webserver.py index 31f6ff436..ecb6680a9 100644 --- a/tests/integration/test_webserver.py +++ b/tests/integration/test_webserver.py @@ -1,4 +1,5 @@ import urllib.request +import urllib.error import pytest @@ -12,7 +13,15 @@ import pytest def test_httpbin(httpbin, qtbot, path, content, expected): with qtbot.waitSignal(httpbin.got_new_url, raising=True, timeout=100): url = 'http://localhost:{}{}'.format(httpbin.port, path) - response = urllib.request.urlopen(url) + try: + response = urllib.request.urlopen(url) + except urllib.error.HTTPError as e: + # "Though being an exception (a subclass of URLError), an HTTPError + # can also function as a non-exceptional file-like return value + # (the same thing that urlopen() returns)." + # ...wat + print(e.read().decode('utf-8')) + raise data = response.read().decode('utf-8')