Show data in test_httpbin.

This commit is contained in:
Florian Bruhin 2015-09-17 07:33:52 +02:00
parent 48b599a774
commit 2bfb7609ac

View File

@ -1,4 +1,5 @@
import urllib.request import urllib.request
import urllib.error
import pytest import pytest
@ -12,7 +13,15 @@ import pytest
def test_httpbin(httpbin, qtbot, path, content, expected): def test_httpbin(httpbin, qtbot, path, content, expected):
with qtbot.waitSignal(httpbin.got_new_url, raising=True, timeout=100): with qtbot.waitSignal(httpbin.got_new_url, raising=True, timeout=100):
url = 'http://localhost:{}{}'.format(httpbin.port, path) url = 'http://localhost:{}{}'.format(httpbin.port, path)
try:
response = urllib.request.urlopen(url) 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') data = response.read().decode('utf-8')