Use httpbin.Request namedtuple for comparisons.

This makes it easier to look at the pytest diff when things go wrong.
This commit is contained in:
Florian Bruhin 2015-10-13 19:37:59 +02:00
parent 6e786ff9b7
commit 8664e45558
3 changed files with 5 additions and 3 deletions

View File

@ -45,10 +45,11 @@ def run_command(quteproc, command):
@bdd.then(bdd.parsers.parse("{path} should be loaded"))
def path_should_be_loaded(httpbin, path):
requests = httpbin.get_requests()
assert requests[-1] == ('GET', '/' + path)
assert requests[-1] == httpbin.Request('GET', '/' + path)
@bdd.then(bdd.parsers.parse("The requests should be:\n{pages}"))
def lost_of_loaded_pages(httpbin, pages):
requests = [('GET', '/' + path.strip()) for path in pages.split('\n')]
requests = [httpbin.Request('GET', '/' + path.strip())
for path in pages.split('\n')]
assert httpbin.get_requests() == requests

View File

@ -46,5 +46,5 @@ def test_httpbin(httpbin, qtbot, path, content, expected):
data = response.read().decode('utf-8')
assert httpbin.get_requests() == [('GET', path)]
assert httpbin.get_requests() == [httpbin.Request('GET', path)]
assert (content in data) == expected

View File

@ -51,6 +51,7 @@ class HTTPBin(testprocess.Process):
"""
new_request = pyqtSignal(Request)
Request = Request # So it can be used from the fixture easily.
LOG_RE = re.compile(r"""
(?P<host>[^ ]*)