bdd: Improve webserver error on unexpected status

pytest 3.0 removed the assertion reinterpretation which made this nice:
https://github.com/pytest-dev/pytest/issues/1871
This commit is contained in:
Florian Bruhin 2016-08-25 22:58:14 +02:00
parent be7abb53ad
commit 2650d9350d

View File

@ -77,7 +77,11 @@ class Request(testprocess.Line):
sanitized = QUrl('http://localhost' + self.path).path() # Remove ?foo
expected_statuses = path_to_statuses.get(sanitized, default_statuses)
assert self.status in expected_statuses
if self.status not in expected_statuses:
raise AssertionError(
"{} loaded with status {} but expected {}".format(
sanitized, self.status,
' / '.join(repr(e) for e in expected_statuses)))
def __eq__(self, other):
return NotImplemented