Skip to content

Commit

Permalink
Provide a more descriptive message on missing header
Browse files Browse the repository at this point in the history
If a test specifies a header which is not present in the response
provide a verbose message of what headers are present.

Fixes #10.
  • Loading branch information
cdent committed Feb 2, 2015
1 parent 5a88364 commit 47669e0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion gabbi/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,14 @@ def _test_headers(self, headers, response):
for header in headers:
header_value = headers[header].replace('$SCHEME', self.scheme)
header_value = header_value.replace('$NETLOC', self.netloc)
response_value = response[header]

try:
response_value = response[header]
except KeyError as exc:
# Reform KeyError to something more debuggable.
raise KeyError("'%s' header not available in response keys: %s"
% (header, response.keys()))

if header_value.startswith('/') and header_value.endswith('/'):
header_value = header_value.strip('/').rstrip('/')
self.assertRegexpMatches(
Expand Down

0 comments on commit 47669e0

Please sign in to comment.