python-urllib3/ready-event.patch
Jan Matejek 5aad292d93 Accepting request 344244 from home:matejcik:branches:devel:languages:python
- removed python-certifi dependency, we don't want to use it
- drop 0001-Don-t-pin-dependency-to-exact-version.patch because it's
  not needed anymore
- re-enable tests, re-add dependencies
  * don't exclude test_util.py
  * exclude proxy timeout tests that fail for spurious reasons
- urllib3-ssl-default-context.patch - use set_default_verify_paths()
  if no certificate path specified and verification not explicitly
  disabled
- urllib3-test-ssl-drop-sslv3.patch - don't use "SSLv3" constants
  as they are not supported in openssl (and conversely python) anymore
- ready-event.patch - fix race conditions in timeout tests

OBS-URL: https://build.opensuse.org/request/show/344244
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-urllib3?expand=0&rev=12
2015-11-13 14:47:50 +00:00

107 lines
4.5 KiB
Diff

Index: urllib3-1.12/dummyserver/testcase.py
===================================================================
--- urllib3-1.12.orig/dummyserver/testcase.py
+++ urllib3-1.12/dummyserver/testcase.py
@@ -45,7 +45,7 @@ class SocketDummyServerTestCase(unittest
def socket_handler(listener):
for _ in range(num):
ready_event.set()
- ready_event.clear()
+ #ready_event.clear()
sock = listener.accept()[0]
consume_socket(sock)
@@ -59,6 +59,11 @@ class SocketDummyServerTestCase(unittest
return ready_event
@classmethod
+ def wait_for_socket(cls, ready_event):
+ ready_event.wait()
+ ready_event.clear()
+
+ @classmethod
def start_basic_handler(cls, **kw):
return cls.start_response_handler(
b'HTTP/1.1 200 OK\r\n'
Index: urllib3-1.12/test/with_dummyserver/test_connectionpool.py
===================================================================
--- urllib3-1.12.orig/test/with_dummyserver/test_connectionpool.py
+++ urllib3-1.12/test/with_dummyserver/test_connectionpool.py
@@ -57,11 +57,12 @@ class TestConnectionPoolTimeouts(SocketD
# Pool-global timeout
pool = HTTPConnectionPool(self.host, self.port, timeout=SHORT_TIMEOUT, retries=False)
+ self.wait_for_socket(ready_event)
self.assertRaises(ReadTimeoutError, pool.request, 'GET', '/')
block_event.set() # Release block
# Shouldn't raise this time
- ready_event.wait()
+ self.wait_for_socket(ready_event)
block_event.set() # Pre-release block
pool.request('GET', '/')
@@ -92,12 +93,13 @@ class TestConnectionPoolTimeouts(SocketD
timeout = Timeout(read=SHORT_TIMEOUT)
pool = HTTPConnectionPool(self.host, self.port, timeout=timeout, retries=False)
+ self.wait_for_socket(ready_event)
conn = pool._get_conn()
self.assertRaises(ReadTimeoutError, pool._make_request, conn, 'GET', '/')
pool._put_conn(conn)
block_event.set() # Release request
- ready_event.wait()
+ self.wait_for_socket(ready_event)
block_event.clear()
self.assertRaises(ReadTimeoutError, pool.request, 'GET', '/')
block_event.set() # Release request
@@ -106,7 +108,7 @@ class TestConnectionPoolTimeouts(SocketD
pool = HTTPConnectionPool(self.host, self.port, timeout=LONG_TIMEOUT, retries=False)
conn = pool._get_conn()
- ready_event.wait()
+ self.wait_for_socket(ready_event)
now = time.time()
self.assertRaises(ReadTimeoutError, pool._make_request, conn, 'GET', '/', timeout=timeout)
delta = time.time() - now
@@ -115,7 +117,7 @@ class TestConnectionPoolTimeouts(SocketD
self.assertTrue(delta < LONG_TIMEOUT, "timeout was pool-level LONG_TIMEOUT rather than request-level SHORT_TIMEOUT")
pool._put_conn(conn)
- ready_event.wait()
+ self.wait_for_socket(ready_event)
now = time.time()
self.assertRaises(ReadTimeoutError, pool.request, 'GET', '/', timeout=timeout)
delta = time.time() - now
@@ -125,11 +127,11 @@ class TestConnectionPoolTimeouts(SocketD
# Timeout int/float passed directly to request and _make_request should
# raise a request timeout
- ready_event.wait()
+ self.wait_for_socket(ready_event)
self.assertRaises(ReadTimeoutError, pool.request, 'GET', '/', timeout=SHORT_TIMEOUT)
block_event.set() # Release request
- ready_event.wait()
+ self.wait_for_socket(ready_event)
conn = pool._new_conn()
# FIXME: This assert flakes sometimes. Not sure why.
self.assertRaises(ReadTimeoutError, pool._make_request, conn, 'GET', '/', timeout=SHORT_TIMEOUT)
@@ -183,13 +185,14 @@ class TestConnectionPoolTimeouts(SocketD
block_event = Event()
ready_event = self.start_basic_handler(block_send=block_event, num=2)
+ self.wait_for_socket(ready_event)
# This will get the socket to raise an EAGAIN on the read
timeout = Timeout(connect=3, read=SHORT_TIMEOUT)
pool = HTTPConnectionPool(self.host, self.port, timeout=timeout, retries=False)
self.assertRaises(ReadTimeoutError, pool.request, 'GET', '/')
block_event.set()
- ready_event.wait()
+ self.wait_for_socket(ready_event)
block_event.clear()
# The connect should succeed and this should hit the read timeout