Closed dolfandringa closed 1 year ago
This is actually a more complex issue to tackle, we should match with respect to case. And this is not the case atm. It should be handled in next release.
Release 0.24.0 handling headers matching a bit more strictly (and with a better error message) is now available on pypi.
With the following test, which correctly matches the Authorization header, but with an incorrect url in this case, the non-matching request causes a very confusing error message that seems to suggest the headers are wrong (besides the url also being wrong):
Running this with pytest results in the following error:
I was expecting it to fail, but it says
with {} header
as if no headers were passed in, while they were.I found out what the issue is: In _explain_that_no_response_was_found it includes
if name in expect_headers}
. The issue is that in the request, theAuthorization
header is turned into lowercase. So this ends up on that line as"authorization" not in {"Authorization": "Bearer: Something"}
, so it won't display the header.