From 5ba4000f774b51a206a8a05b208f5c637010d42d Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Tue, 26 Nov 2013 12:07:13 -0800 Subject: [PATCH] Add test: test_session_and_connection_close This is a test for issue GH-48. --- tests/integration/test_requests.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/integration/test_requests.py b/tests/integration/test_requests.py index e399098..5153b3c 100644 --- a/tests/integration/test_requests.py +++ b/tests/integration/test_requests.py @@ -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'})