Skip to content

Commit

Permalink
Add test: test_session_and_connection_close
Browse files Browse the repository at this point in the history
This is a test for issue GH-48.
  • Loading branch information
msabramo committed Nov 26, 2013
1 parent a4844d9 commit 5ba4000
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/integration/test_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,18 @@ def test_gzip(tmpdir, scheme):

with vcr.use_cassette(str(tmpdir.join('gzip.yaml'))) as cass:
assert_is_json(response.content)


def test_session_and_connection_close(tmpdir, scheme):
'''
This tests the issue in https://github.com/kevin1024/vcrpy/issues/48
If you use a requests.session and the connection is closed, then an
exception is raised in the urllib3 module vendored into requests:
`AttributeError: 'NoneType' object has no attribute 'settimeout'`
'''
with vcr.use_cassette(str(tmpdir.join('session_connection_closed.yaml'))):
session = requests.session()

resp = session.get('http://httpbin.org/get', headers={'Connection': 'close'})
resp = session.get('http://httpbin.org/get', headers={'Connection': 'close'})

0 comments on commit 5ba4000

Please sign in to comment.