You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
git clone https://github.com/httpie/httpie; cd httpie
pip install 'responses>=0.22.0' .[test]
pytest
Current result
A multitude of failures in tests/test_encoding.py, tests/test_json.py, etc. in the vein of https://hydra.nixos.org/build/202035507: KeyError: 0 on httpie/models.py line 82.
Expected result
A passing test suite.
Additional information, screenshots, or code examples
I wrote some of this up in NixOS/nixpkgs#205270 (comment), but the problem is not NixOS-specific. The short version is that before getsentry/responses#585, the reference to httpie.models.HTTPResponse()._orig.raw._original_response.version in the implementation of httpie.models.HTTPResponse.headers found the then-extant responses.OriginalResponseShim object, which does not have a version attribute, and therefore successfully defaulted to 11, whereas now that that class has been removed it finds a urllib3.HTTPResponse object instead, which defaults to version=0, and it’s not prepared to handle that.
Given the amount of groveling into internal data structures that goes on here (I don’t think requests even documents Request.raw as being a urllib3.HTTPResponse object), I’m not sure if this is a bug in the httpie test suite or a regression in responses, so I’m filing it here for you to decide.
For reference, the following change makes the tests pass for me:
diff --git a/httpie/models.py b/httpie/models.py
index d97b55e..a3ec6e7 100644
--- a/httpie/models.py+++ b/httpie/models.py@@ -77,6 +77,8 @@ class HTTPResponse(HTTPMessage):
else:
raw_version = raw.version
except AttributeError:
+ raw_version = 0+ if not raw_version:
# Assume HTTP/1.1
raw_version = 11
version = {
The text was updated successfully, but these errors were encountered:
Checklist
Minimal reproduction code and steps
git clone https://github.com/httpie/httpie; cd httpie
pip install 'responses>=0.22.0' .[test]
pytest
Current result
A multitude of failures in
tests/test_encoding.py
,tests/test_json.py
, etc. in the vein of https://hydra.nixos.org/build/202035507:KeyError: 0
on httpie/models.py line 82.Expected result
A passing test suite.
Additional information, screenshots, or code examples
I wrote some of this up in NixOS/nixpkgs#205270 (comment), but the problem is not NixOS-specific. The short version is that before getsentry/responses#585, the reference to
httpie.models.HTTPResponse()._orig.raw._original_response.version
in the implementation ofhttpie.models.HTTPResponse.headers
found the then-extantresponses.OriginalResponseShim
object, which does not have aversion
attribute, and therefore successfully defaulted to 11, whereas now that that class has been removed it finds aurllib3.HTTPResponse
object instead, which defaults toversion
=0, and it’s not prepared to handle that.Given the amount of groveling into internal data structures that goes on here (I don’t think
requests
even documentsRequest.raw
as being aurllib3.HTTPResponse
object), I’m not sure if this is a bug in thehttpie
test suite or a regression inresponses
, so I’m filing it here for you to decide.For reference, the following change makes the tests pass for me:
The text was updated successfully, but these errors were encountered: