From 2bfb7609ac93a59eaf1f6ac324aa2fcdd2b9a3b8 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 17 Sep 2015 07:33:52 +0200 Subject: [PATCH] Show data in test_httpbin. --- tests/integration/test_webserver.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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')