Multiple test failures in test_sessions.py
.
When I run:
tox -e py34 -- tests/test_sessions.py
I get 1, 2, or 3 test failures out of the 7 total tests in that module.
tests/test_sessions.py::TestSessionFlow::test_session_created_and_reused PASSED
tests/test_sessions.py::TestSessionFlow::test_session_update FAILED
tests/test_sessions.py::TestSessionFlow::test_session_read_only FAILED
tests/test_sessions.py::TestSession::test_session_ignored_header_prefixes PASSED
tests/test_sessions.py::TestSession::test_session_by_path PASSED
tests/test_sessions.py::TestSession::test_session_unicode FAILED
tests/test_sessions.py::TestSession::test_session_default_header_value_overwritten PASSED
More info:
TestSessionFlow.test_session_update
fails with:
...
requests.exceptions.ConnectionError: (
'Connection aborted.', ConnectionResetError(54, 'Connection reset by peer'))
pdb for above error shows:
> /Users/marca/dev/git-repos/httpie/.tox/py34/lib/python3.4/site-packages/requests/adapters.py(407)send()
-> raise ConnectionError(err, request=request)
(Pdb) up
> /Users/marca/dev/git-repos/httpie/.tox/py34/lib/python3.4/site-packages/requests/sessions.py(569)send()
-> r = adapter.send(request, **kwargs)
(Pdb) request.method
'GET'
(Pdb) request.url
'http://127.0.0.1:56308/cookies'
(Pdb) request.headers
{'Accept-Encoding': 'gzip, deflate', 'Hello': b'World2', 'Cookie': 'hello=world; hello=world2', 'Connection': 'keep-alive', 'Authorization': b'Basic dXNlcm5hbWU6cGFzc3dvcmQy', 'Accept': '*/*', 'User-Agent': b'HTTPie/0.9.0-dev'}
(Pdb) kwargs
{'timeout': 30, 'cert': None, 'proxies': {}, 'stream': True, 'verify': True}
TestSessionFlow.test_session_read_only
fails with
...
requests.exceptions.ConnectionError: ('Connection aborted.', BadStatusLine("''",))
pdb for above error shows:
> /Users/marca/dev/git-repos/httpie/.tox/py34/lib/python3.4/site-packages/requests/adapters.py(407)send()
-> raise ConnectionError(err, request=request)
(Pdb) up
> /Users/marca/dev/git-repos/httpie/.tox/py34/lib/python3.4/site-packages/requests/sessions.py(569)send()
-> r = adapter.send(request, **kwargs)
(Pdb) request.method
'GET'
(Pdb) request.url
'http://127.0.0.1:56276/cookies'
(Pdb) request.headers
{'User-Agent': b'HTTPie/0.9.0-dev', 'Hello': b'World2', 'Accept-Encoding': 'gzip, deflate', 'Cookie': 'hello=world; hello=world2', 'Connection': 'keep-alive', 'Authorization': b'Basic dXNlcm5hbWU6cGFzc3dvcmQy', 'Accept': '*/*'}
(Pdb) kwargs
{'cert': None, 'proxies': {}, 'verify': True, 'timeout': 30, 'stream': True}
TestSession.test_session_unicode
fails with:
...
Traceback (most recent call last):
File ".../httpie/tests/test_sessions.py", line 148, in test_session_unicode
assert (r2.json['headers']['Authorization']
KeyError: 'Authorization'
Pertaining to this last error, there is a comment in the test saying:
147 # FIXME: Authorization *sometimes* is not present on Python3
(Pdb) pprint.pprint(r2.json)
{'args': {},
'headers': {'Content-Length': '',
'Host': '127.0.0.1:56230',
'Test': '[one line of UTF8-encoded unicode text] Ï\x87Ï\x81Ï'},
'origin': '127.0.0.1',
'url': 'http://127.0.0.1:56230/get'}
In py33 I also see 1 to 2 test failures -- I have not yet observed TestSession.test_session_unicode
failing on py33.
Most of the time, all these tests pass on py27, though I am seeing test_session_read_only
fail occasionally with:
____________________________________________________________________ TestSessionFlow.test_session_read_only ____________________________________________________________________
Traceback (most recent call last):
File "/Users/marca/dev/git-repos/httpie/tests/test_sessions.py", line 82, in test_session_read_only
self.start_session(httpbin)
File "/Users/marca/dev/git-repos/httpie/tests/test_sessions.py", line 48, in start_session
env=self.env())
File "/Users/marca/dev/git-repos/httpie/tests/utils.py", line 136, in http
exit_status = main(args=args, **kwargs)
File "/Users/marca/dev/git-repos/httpie/.tox/py27/lib/python2.7/site-packages/httpie/core.py", line 112, in main
response = get_response(args, config_dir=env.config.directory)
File "/Users/marca/dev/git-repos/httpie/.tox/py27/lib/python2.7/site-packages/httpie/client.py", line 31, in get_response
read_only=bool(args.session_read_only),
File "/Users/marca/dev/git-repos/httpie/.tox/py27/lib/python2.7/site-packages/httpie/sessions.py", line 65, in get_response
response = requests_session.request(**requests_kwargs)
File "/Users/marca/dev/git-repos/httpie/.tox/py27/lib/python2.7/site-packages/requests/sessions.py", line 457, in request
resp = self.send(prep, **send_kwargs)
File "/Users/marca/dev/git-repos/httpie/.tox/py27/lib/python2.7/site-packages/requests/sessions.py", line 595, in send
history = [resp for resp in gen] if allow_redirects else []
File "/Users/marca/dev/git-repos/httpie/.tox/py27/lib/python2.7/site-packages/requests/sessions.py", line 189, in resolve_redirects
allow_redirects=False,
File "/Users/marca/dev/git-repos/httpie/.tox/py27/lib/python2.7/site-packages/requests/sessions.py", line 569, in send
r = adapter.send(request, **kwargs)
File "/Users/marca/dev/git-repos/httpie/.tox/py27/lib/python2.7/site-packages/requests/adapters.py", line 407, in send
raise ConnectionError(err, request=request)
ConnectionError: ('Connection aborted.', error(54, 'Connection reset by peer'))