aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/__init__.pycbin3946 -> 0 bytes
-rw-r--r--test/contrib/__init__.pycbin142 -> 0 bytes
-rw-r--r--test/contrib/test_pyopenssl.pycbin1143 -> 0 bytes
-rw-r--r--test/port_helpers.pycbin5719 -> 0 bytes
-rw-r--r--test/test_collections.pycbin6842 -> 0 bytes
-rw-r--r--test/test_compatibility.pycbin1372 -> 0 bytes
-rw-r--r--test/test_connectionpool.py2
-rw-r--r--test/test_connectionpool.pycbin8862 -> 0 bytes
-rw-r--r--test/test_exceptions.pycbin1931 -> 0 bytes
-rw-r--r--test/test_fields.pycbin2739 -> 0 bytes
-rw-r--r--test/test_filepost.pycbin4916 -> 0 bytes
-rw-r--r--test/test_poolmanager.pycbin2499 -> 0 bytes
-rw-r--r--test/test_proxymanager.pycbin1670 -> 0 bytes
-rw-r--r--test/test_response.pycbin14619 -> 0 bytes
-rw-r--r--test/test_retry.py44
-rw-r--r--test/test_retry.pycbin6491 -> 0 bytes
-rw-r--r--test/test_util.py121
-rw-r--r--test/test_util.pycbin15036 -> 0 bytes
-rw-r--r--test/with_dummyserver/__init__.pycbin151 -> 0 bytes
-rw-r--r--test/with_dummyserver/test_connectionpool.py12
-rw-r--r--test/with_dummyserver/test_connectionpool.pycbin27640 -> 0 bytes
-rw-r--r--test/with_dummyserver/test_https.py36
-rw-r--r--test/with_dummyserver/test_https.pycbin15651 -> 0 bytes
-rw-r--r--test/with_dummyserver/test_poolmanager.pycbin5591 -> 0 bytes
-rw-r--r--test/with_dummyserver/test_proxy_poolmanager.py28
-rw-r--r--test/with_dummyserver/test_proxy_poolmanager.pycbin9891 -> 0 bytes
-rw-r--r--test/with_dummyserver/test_socketlevel.py18
-rw-r--r--test/with_dummyserver/test_socketlevel.pycbin18715 -> 0 bytes
28 files changed, 211 insertions, 50 deletions
diff --git a/test/__init__.pyc b/test/__init__.pyc
deleted file mode 100644
index 38b9317..0000000
--- a/test/__init__.pyc
+++ /dev/null
Binary files differ
diff --git a/test/contrib/__init__.pyc b/test/contrib/__init__.pyc
deleted file mode 100644
index 2d2fd5d..0000000
--- a/test/contrib/__init__.pyc
+++ /dev/null
Binary files differ
diff --git a/test/contrib/test_pyopenssl.pyc b/test/contrib/test_pyopenssl.pyc
deleted file mode 100644
index 6441273..0000000
--- a/test/contrib/test_pyopenssl.pyc
+++ /dev/null
Binary files differ
diff --git a/test/port_helpers.pyc b/test/port_helpers.pyc
deleted file mode 100644
index 7a1c425..0000000
--- a/test/port_helpers.pyc
+++ /dev/null
Binary files differ
diff --git a/test/test_collections.pyc b/test/test_collections.pyc
deleted file mode 100644
index d1ecd73..0000000
--- a/test/test_collections.pyc
+++ /dev/null
Binary files differ
diff --git a/test/test_compatibility.pyc b/test/test_compatibility.pyc
deleted file mode 100644
index 2dfdf75..0000000
--- a/test/test_compatibility.pyc
+++ /dev/null
Binary files differ
diff --git a/test/test_connectionpool.py b/test/test_connectionpool.py
index 28fb89b..a6dbcf4 100644
--- a/test/test_connectionpool.py
+++ b/test/test_connectionpool.py
@@ -118,7 +118,7 @@ class TestConnectionPool(unittest.TestCase):
str(MaxRetryError(
HTTPConnectionPool(host='localhost'), "Test.", None)),
"HTTPConnectionPool(host='localhost', port=None): "
- "Max retries exceeded with url: Test. (Caused by redirect)")
+ "Max retries exceeded with url: Test. (Caused by None)")
err = SocketError("Test")
diff --git a/test/test_connectionpool.pyc b/test/test_connectionpool.pyc
deleted file mode 100644
index e87a3b3..0000000
--- a/test/test_connectionpool.pyc
+++ /dev/null
Binary files differ
diff --git a/test/test_exceptions.pyc b/test/test_exceptions.pyc
deleted file mode 100644
index 3274e34..0000000
--- a/test/test_exceptions.pyc
+++ /dev/null
Binary files differ
diff --git a/test/test_fields.pyc b/test/test_fields.pyc
deleted file mode 100644
index 4622899..0000000
--- a/test/test_fields.pyc
+++ /dev/null
Binary files differ
diff --git a/test/test_filepost.pyc b/test/test_filepost.pyc
deleted file mode 100644
index ec54472..0000000
--- a/test/test_filepost.pyc
+++ /dev/null
Binary files differ
diff --git a/test/test_poolmanager.pyc b/test/test_poolmanager.pyc
deleted file mode 100644
index 077c2ac..0000000
--- a/test/test_poolmanager.pyc
+++ /dev/null
Binary files differ
diff --git a/test/test_proxymanager.pyc b/test/test_proxymanager.pyc
deleted file mode 100644
index 3696ee8..0000000
--- a/test/test_proxymanager.pyc
+++ /dev/null
Binary files differ
diff --git a/test/test_response.pyc b/test/test_response.pyc
deleted file mode 100644
index 99e5c0e..0000000
--- a/test/test_response.pyc
+++ /dev/null
Binary files differ
diff --git a/test/test_retry.py b/test/test_retry.py
index 7a3aa40..421e508 100644
--- a/test/test_retry.py
+++ b/test/test_retry.py
@@ -1,11 +1,13 @@
import unittest
+from urllib3.response import HTTPResponse
from urllib3.packages.six.moves import xrange
from urllib3.util.retry import Retry
from urllib3.exceptions import (
ConnectTimeoutError,
+ MaxRetryError,
ReadTimeoutError,
- MaxRetryError
+ ResponseError,
)
@@ -154,3 +156,43 @@ class RetryTest(unittest.TestCase):
def test_disabled(self):
self.assertRaises(MaxRetryError, Retry(-1).increment)
self.assertRaises(MaxRetryError, Retry(0).increment)
+
+ def test_error_message(self):
+ retry = Retry(total=0)
+ try:
+ retry = retry.increment(error=ReadTimeoutError(None, "/", "read timed out"))
+ raise AssertionError("Should have raised a MaxRetryError")
+ except MaxRetryError as e:
+ assert 'Caused by redirect' not in str(e)
+ self.assertEqual(str(e.reason), 'None: read timed out')
+
+ retry = Retry(total=1)
+ try:
+ retry = retry.increment('POST', '/')
+ retry = retry.increment('POST', '/')
+ raise AssertionError("Should have raised a MaxRetryError")
+ except MaxRetryError as e:
+ assert 'Caused by redirect' not in str(e)
+ self.assertTrue(isinstance(e.reason, ResponseError),
+ "%s should be a ResponseError" % e.reason)
+ self.assertEqual(str(e.reason), ResponseError.GENERIC_ERROR)
+
+ retry = Retry(total=1)
+ try:
+ response = HTTPResponse(status=500)
+ retry = retry.increment('POST', '/', response=response)
+ retry = retry.increment('POST', '/', response=response)
+ raise AssertionError("Should have raised a MaxRetryError")
+ except MaxRetryError as e:
+ assert 'Caused by redirect' not in str(e)
+ msg = ResponseError.SPECIFIC_ERROR.format(status_code=500)
+ self.assertEqual(str(e.reason), msg)
+
+ retry = Retry(connect=1)
+ try:
+ retry = retry.increment(error=ConnectTimeoutError('conntimeout'))
+ retry = retry.increment(error=ConnectTimeoutError('conntimeout'))
+ raise AssertionError("Should have raised a MaxRetryError")
+ except MaxRetryError as e:
+ assert 'Caused by redirect' not in str(e)
+ self.assertEqual(str(e.reason), 'conntimeout')
diff --git a/test/test_retry.pyc b/test/test_retry.pyc
deleted file mode 100644
index 398c010..0000000
--- a/test/test_retry.pyc
+++ /dev/null
Binary files differ
diff --git a/test/test_util.py b/test/test_util.py
index 1811dbd..c850d91 100644
--- a/test/test_util.py
+++ b/test/test_util.py
@@ -2,8 +2,9 @@ import warnings
import logging
import unittest
import ssl
+from itertools import chain
-from mock import patch
+from mock import patch, Mock
from urllib3 import add_stderr_logger, disable_warnings
from urllib3.util.request import make_headers
@@ -14,14 +15,15 @@ from urllib3.util.url import (
split_first,
Url,
)
-from urllib3.util.ssl_ import resolve_cert_reqs
+from urllib3.util.ssl_ import resolve_cert_reqs, ssl_wrap_socket
from urllib3.exceptions import (
LocationParseError,
TimeoutStateError,
InsecureRequestWarning,
+ SSLError,
)
-from urllib3.util import is_fp_closed
+from urllib3.util import is_fp_closed, ssl_
from . import clear_warnings
@@ -89,45 +91,61 @@ class TestUtil(unittest.TestCase):
self.assertRaises(LocationParseError, get_host, location)
- def test_parse_url(self):
- url_host_map = {
- 'http://google.com/mail': Url('http', host='google.com', path='/mail'),
- 'http://google.com/mail/': Url('http', host='google.com', path='/mail/'),
- 'google.com/mail': Url(host='google.com', path='/mail'),
- 'http://google.com/': Url('http', host='google.com', path='/'),
- 'http://google.com': Url('http', host='google.com'),
- 'http://google.com?foo': Url('http', host='google.com', path='', query='foo'),
-
- # Path/query/fragment
- '': Url(),
- '/': Url(path='/'),
- '?': Url(path='', query=''),
- '#': Url(path='', fragment=''),
- '#?/!google.com/?foo#bar': Url(path='', fragment='?/!google.com/?foo#bar'),
- '/foo': Url(path='/foo'),
- '/foo?bar=baz': Url(path='/foo', query='bar=baz'),
- '/foo?bar=baz#banana?apple/orange': Url(path='/foo', query='bar=baz', fragment='banana?apple/orange'),
-
- # Port
- 'http://google.com/': Url('http', host='google.com', path='/'),
- 'http://google.com:80/': Url('http', host='google.com', port=80, path='/'),
- 'http://google.com:/': Url('http', host='google.com', path='/'),
- 'http://google.com:80': Url('http', host='google.com', port=80),
- 'http://google.com:': Url('http', host='google.com'),
-
- # Auth
- 'http://foo:bar@localhost/': Url('http', auth='foo:bar', host='localhost', path='/'),
- 'http://foo@localhost/': Url('http', auth='foo', host='localhost', path='/'),
- 'http://foo:bar@baz@localhost/': Url('http', auth='foo:bar@baz', host='localhost', path='/'),
- 'http://@': Url('http', host=None, auth='')
+ parse_url_host_map = {
+ 'http://google.com/mail': Url('http', host='google.com', path='/mail'),
+ 'http://google.com/mail/': Url('http', host='google.com', path='/mail/'),
+ 'google.com/mail': Url(host='google.com', path='/mail'),
+ 'http://google.com/': Url('http', host='google.com', path='/'),
+ 'http://google.com': Url('http', host='google.com'),
+ 'http://google.com?foo': Url('http', host='google.com', path='', query='foo'),
+
+ # Path/query/fragment
+ '': Url(),
+ '/': Url(path='/'),
+ '#?/!google.com/?foo#bar': Url(path='', fragment='?/!google.com/?foo#bar'),
+ '/foo': Url(path='/foo'),
+ '/foo?bar=baz': Url(path='/foo', query='bar=baz'),
+ '/foo?bar=baz#banana?apple/orange': Url(path='/foo', query='bar=baz', fragment='banana?apple/orange'),
+
+ # Port
+ 'http://google.com/': Url('http', host='google.com', path='/'),
+ 'http://google.com:80/': Url('http', host='google.com', port=80, path='/'),
+ 'http://google.com:80': Url('http', host='google.com', port=80),
+
+ # Auth
+ 'http://foo:bar@localhost/': Url('http', auth='foo:bar', host='localhost', path='/'),
+ 'http://foo@localhost/': Url('http', auth='foo', host='localhost', path='/'),
+ 'http://foo:bar@baz@localhost/': Url('http', auth='foo:bar@baz', host='localhost', path='/'),
+ 'http://@': Url('http', host=None, auth='')
+ }
+
+ non_round_tripping_parse_url_host_map = {
+ # Path/query/fragment
+ '?': Url(path='', query=''),
+ '#': Url(path='', fragment=''),
+
+ # Empty Port
+ 'http://google.com:': Url('http', host='google.com'),
+ 'http://google.com:/': Url('http', host='google.com', path='/'),
+
}
- for url, expected_url in url_host_map.items():
- returned_url = parse_url(url)
- self.assertEqual(returned_url, expected_url)
+
+ def test_parse_url(self):
+ for url, expected_Url in chain(self.parse_url_host_map.items(), self.non_round_tripping_parse_url_host_map.items()):
+ returned_Url = parse_url(url)
+ self.assertEqual(returned_Url, expected_Url)
+
+ def test_unparse_url(self):
+ for url, expected_Url in self.parse_url_host_map.items():
+ self.assertEqual(url, expected_Url.url)
def test_parse_url_invalid_IPv6(self):
self.assertRaises(ValueError, parse_url, '[::1')
+ def test_Url_str(self):
+ U = Url('http', host='google.com')
+ self.assertEqual(str(U), U.url)
+
def test_request_uri(self):
url_host_map = {
'http://google.com/mail': '/mail',
@@ -333,7 +351,7 @@ class TestUtil(unittest.TestCase):
return True
self.assertTrue(is_fp_closed(ClosedFile()))
-
+
def test_is_fp_closed_object_has_none_fp(self):
class NoneFpFile(object):
@property
@@ -355,3 +373,30 @@ class TestUtil(unittest.TestCase):
pass
self.assertRaises(ValueError, is_fp_closed, NotReallyAFile())
+
+ def test_ssl_wrap_socket_loads_the_cert_chain(self):
+ socket = object()
+ mock_context = Mock()
+ ssl_wrap_socket(ssl_context=mock_context, sock=socket,
+ certfile='/path/to/certfile')
+
+ mock_context.load_cert_chain.assert_called_once_with(
+ '/path/to/certfile', None)
+
+ def test_ssl_wrap_socket_loads_verify_locations(self):
+ socket = object()
+ mock_context = Mock()
+ ssl_wrap_socket(ssl_context=mock_context, ca_certs='/path/to/pem',
+ sock=socket)
+ mock_context.load_verify_locations.assert_called_once_with(
+ '/path/to/pem')
+
+ def test_ssl_wrap_socket_with_no_sni(self):
+ socket = object()
+ mock_context = Mock()
+ # Ugly preservation of original value
+ HAS_SNI = ssl_.HAS_SNI
+ ssl_.HAS_SNI = False
+ ssl_wrap_socket(ssl_context=mock_context, sock=socket)
+ mock_context.wrap_socket.assert_called_once_with(socket)
+ ssl_.HAS_SNI = HAS_SNI
diff --git a/test/test_util.pyc b/test/test_util.pyc
deleted file mode 100644
index 0500c3b..0000000
--- a/test/test_util.pyc
+++ /dev/null
Binary files differ
diff --git a/test/with_dummyserver/__init__.pyc b/test/with_dummyserver/__init__.pyc
deleted file mode 100644
index 833be60..0000000
--- a/test/with_dummyserver/__init__.pyc
+++ /dev/null
Binary files differ
diff --git a/test/with_dummyserver/test_connectionpool.py b/test/with_dummyserver/test_connectionpool.py
index 7d54fbf..cc0f011 100644
--- a/test/with_dummyserver/test_connectionpool.py
+++ b/test/with_dummyserver/test_connectionpool.py
@@ -13,8 +13,7 @@ except:
from urllib import urlencode
from .. import (
- requires_network,
- onlyPy3, onlyPy27OrNewer, onlyPy26OrOlder,
+ requires_network, onlyPy3, onlyPy26OrOlder,
TARPIT_HOST, VALID_SOURCE_ADDRESSES, INVALID_SOURCE_ADDRESSES,
)
from ..port_helpers import find_unused_port
@@ -99,6 +98,13 @@ class TestConnectionPool(HTTPDummyServerTestCase):
r = self.pool.request('POST', '/echo', fields=fields)
self.assertEqual(r.data.count(b'name="foo"'), 2)
+ def test_request_method_body(self):
+ body = b'hi'
+ r = self.pool.request('POST', '/echo', body=body)
+ self.assertEqual(r.data, body)
+
+ fields = [('hi', 'hello')]
+ self.assertRaises(TypeError, self.pool.request, 'POST', '/echo', body=body, fields=fields)
def test_unicode_upload(self):
fieldname = u('myfile')
@@ -189,7 +195,7 @@ class TestConnectionPool(HTTPDummyServerTestCase):
@timed(0.5)
def test_timeout(self):
""" Requests should time out when expected """
- url = '/sleep?seconds=0.002'
+ url = '/sleep?seconds=0.003'
timeout = Timeout(read=0.001)
# Pool-global timeout
diff --git a/test/with_dummyserver/test_connectionpool.pyc b/test/with_dummyserver/test_connectionpool.pyc
deleted file mode 100644
index b8c38e9..0000000
--- a/test/with_dummyserver/test_connectionpool.pyc
+++ /dev/null
Binary files differ
diff --git a/test/with_dummyserver/test_https.py b/test/with_dummyserver/test_https.py
index cf3eee7..16ca589 100644
--- a/test/with_dummyserver/test_https.py
+++ b/test/with_dummyserver/test_https.py
@@ -9,7 +9,8 @@ import mock
from nose.plugins.skip import SkipTest
from dummyserver.testcase import HTTPSDummyServerTestCase
-from dummyserver.server import DEFAULT_CA, DEFAULT_CA_BAD, DEFAULT_CERTS
+from dummyserver.server import (DEFAULT_CA, DEFAULT_CA_BAD, DEFAULT_CERTS,
+ NO_SAN_CERTS, NO_SAN_CA)
from test import (
onlyPy26OrOlder,
@@ -168,7 +169,7 @@ class TestHTTPS(HTTPSDummyServerTestCase):
https_pool.request('HEAD', '/')
def test_assert_hostname_false(self):
- https_pool = HTTPSConnectionPool('127.0.0.1', self.port,
+ https_pool = HTTPSConnectionPool('localhost', self.port,
cert_reqs='CERT_REQUIRED',
ca_certs=DEFAULT_CA)
@@ -176,7 +177,7 @@ class TestHTTPS(HTTPSDummyServerTestCase):
https_pool.request('GET', '/')
def test_assert_specific_hostname(self):
- https_pool = HTTPSConnectionPool('127.0.0.1', self.port,
+ https_pool = HTTPSConnectionPool('localhost', self.port,
cert_reqs='CERT_REQUIRED',
ca_certs=DEFAULT_CA)
@@ -184,7 +185,7 @@ class TestHTTPS(HTTPSDummyServerTestCase):
https_pool.request('GET', '/')
def test_assert_fingerprint_md5(self):
- https_pool = HTTPSConnectionPool('127.0.0.1', self.port,
+ https_pool = HTTPSConnectionPool('localhost', self.port,
cert_reqs='CERT_REQUIRED',
ca_certs=DEFAULT_CA)
@@ -193,7 +194,7 @@ class TestHTTPS(HTTPSDummyServerTestCase):
https_pool.request('GET', '/')
def test_assert_fingerprint_sha1(self):
- https_pool = HTTPSConnectionPool('127.0.0.1', self.port,
+ https_pool = HTTPSConnectionPool('localhost', self.port,
cert_reqs='CERT_REQUIRED',
ca_certs=DEFAULT_CA)
@@ -329,6 +330,8 @@ class TestHTTPS(HTTPSDummyServerTestCase):
https_pool._make_request(conn, 'GET', '/')
def test_ssl_correct_system_time(self):
+ self._pool.cert_reqs = 'CERT_REQUIRED'
+ self._pool.ca_certs = DEFAULT_CA
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always')
self._pool.request('GET', '/')
@@ -336,6 +339,8 @@ class TestHTTPS(HTTPSDummyServerTestCase):
self.assertEqual([], w)
def test_ssl_wrong_system_time(self):
+ self._pool.cert_reqs = 'CERT_REQUIRED'
+ self._pool.ca_certs = DEFAULT_CA
with mock.patch('urllib3.connection.datetime') as mock_date:
mock_date.date.today.return_value = datetime.date(1970, 1, 1)
@@ -369,6 +374,27 @@ class TestHTTPS_TLSv1(HTTPSDummyServerTestCase):
self._pool.ssl_version = 'SSLv3'
self.assertRaises(SSLError, self._pool.request, 'GET', '/')
+ def test_discards_connection_on_sslerror(self):
+ self._pool.cert_reqs = 'CERT_REQUIRED'
+ self.assertRaises(SSLError, self._pool.request, 'GET', '/')
+ self._pool.ca_certs = DEFAULT_CA
+ self._pool.request('GET', '/')
+
+
+class TestHTTPS_NoSAN(HTTPSDummyServerTestCase):
+ certs = NO_SAN_CERTS
+
+ def test_warning_for_certs_without_a_san(self):
+ """Ensure that a warning is raised when the cert from the server has
+ no Subject Alternative Name."""
+ with mock.patch('warnings.warn') as warn:
+ https_pool = HTTPSConnectionPool(self.host, self.port,
+ cert_reqs='CERT_REQUIRED',
+ ca_certs=NO_SAN_CA)
+ r = https_pool.request('GET', '/')
+ self.assertEqual(r.status, 200)
+ self.assertTrue(warn.called)
+
if __name__ == '__main__':
unittest.main()
diff --git a/test/with_dummyserver/test_https.pyc b/test/with_dummyserver/test_https.pyc
deleted file mode 100644
index 6d85316..0000000
--- a/test/with_dummyserver/test_https.pyc
+++ /dev/null
Binary files differ
diff --git a/test/with_dummyserver/test_poolmanager.pyc b/test/with_dummyserver/test_poolmanager.pyc
deleted file mode 100644
index 26c52e9..0000000
--- a/test/with_dummyserver/test_poolmanager.pyc
+++ /dev/null
Binary files differ
diff --git a/test/with_dummyserver/test_proxy_poolmanager.py b/test/with_dummyserver/test_proxy_poolmanager.py
index 61eedf1..df300fe 100644
--- a/test/with_dummyserver/test_proxy_poolmanager.py
+++ b/test/with_dummyserver/test_proxy_poolmanager.py
@@ -1,13 +1,17 @@
-import unittest
import json
import socket
+import unittest
+
+from nose.tools import timed
from dummyserver.testcase import HTTPDummyProxyTestCase
from dummyserver.server import (
DEFAULT_CA, DEFAULT_CA_BAD, get_unreachable_address)
+from .. import TARPIT_HOST
from urllib3.poolmanager import proxy_from_url, ProxyManager
-from urllib3.exceptions import MaxRetryError, SSLError, ProxyError
+from urllib3.exceptions import (
+ MaxRetryError, SSLError, ProxyError, ConnectTimeoutError)
from urllib3.connectionpool import connection_from_url, VerifiedHTTPSConnection
@@ -259,5 +263,25 @@ class TestHTTPProxyManager(HTTPDummyProxyTestCase):
self.assertEqual(sc3,sc4)
+ @timed(0.5)
+ def test_https_proxy_timeout(self):
+ https = proxy_from_url('https://{host}'.format(host=TARPIT_HOST))
+ try:
+ https.request('GET', self.http_url, timeout=0.001)
+ self.fail("Failed to raise retry error.")
+ except MaxRetryError as e:
+ assert isinstance(e.reason, ConnectTimeoutError)
+
+
+ @timed(0.5)
+ def test_https_proxy_pool_timeout(self):
+ https = proxy_from_url('https://{host}'.format(host=TARPIT_HOST),
+ timeout=0.001)
+ try:
+ https.request('GET', self.http_url)
+ self.fail("Failed to raise retry error.")
+ except MaxRetryError as e:
+ assert isinstance(e.reason, ConnectTimeoutError)
+
if __name__ == '__main__':
unittest.main()
diff --git a/test/with_dummyserver/test_proxy_poolmanager.pyc b/test/with_dummyserver/test_proxy_poolmanager.pyc
deleted file mode 100644
index 12c320c..0000000
--- a/test/with_dummyserver/test_proxy_poolmanager.pyc
+++ /dev/null
Binary files differ
diff --git a/test/with_dummyserver/test_socketlevel.py b/test/with_dummyserver/test_socketlevel.py
index e1ac1c6..c1ef1be 100644
--- a/test/with_dummyserver/test_socketlevel.py
+++ b/test/with_dummyserver/test_socketlevel.py
@@ -137,6 +137,24 @@ class TestSocketClosing(SocketDummyServerTestCase):
finally:
timed_out.set()
+ def test_https_connection_read_timeout(self):
+ """ Handshake timeouts should fail with a Timeout"""
+ timed_out = Event()
+ def socket_handler(listener):
+ sock = listener.accept()[0]
+ while not sock.recv(65536):
+ pass
+
+ timed_out.wait()
+ sock.close()
+
+ self._start_server(socket_handler)
+ pool = HTTPSConnectionPool(self.host, self.port, timeout=0.001, retries=False)
+ try:
+ self.assertRaises(ReadTimeoutError, pool.request, 'GET', '/')
+ finally:
+ timed_out.set()
+
def test_timeout_errors_cause_retries(self):
def socket_handler(listener):
sock_timeout = listener.accept()[0]
diff --git a/test/with_dummyserver/test_socketlevel.pyc b/test/with_dummyserver/test_socketlevel.pyc
deleted file mode 100644
index ba3b19e..0000000
--- a/test/with_dummyserver/test_socketlevel.pyc
+++ /dev/null
Binary files differ