summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Arthur <thruflo@gmail.com>2013-04-19 10:57:20 +0100
committerJames Arthur <thruflo@gmail.com>2013-04-19 10:57:22 +0100
commit5586443c04a3e939cabec778a920eaa97991c3dc (patch)
tree77d7f04a53a4b1055071e576f7b2fc51aebbf3a7
parentdc579672557173303560fbafd76f41921cbdd821 (diff)
downloadredis-py-5586443c04a3e939cabec778a920eaa97991c3dc.tar.gz
tests: tweak blocking connection pool test.
Previously the `test_max_connections_blocks` test wasn't actually testing that the connection was blocking.
-rw-r--r--tests/connection_pool.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/tests/connection_pool.py b/tests/connection_pool.py
index a083fec..91d4d46 100644
--- a/tests/connection_pool.py
+++ b/tests/connection_pool.py
@@ -84,22 +84,24 @@ class BlockingConnectionPoolTestCase(unittest.TestCase):
from Queue import Queue
q = Queue()
+ q.put_nowait('Not yet got')
pool = self.get_pool(max_connections=2, timeout=5)
c1 = pool.get_connection('_')
c2 = pool.get_connection('_')
- c3 = 'Not yet got'
-
+
target = lambda: q.put_nowait(pool.get_connection('_'))
Thread(target=target).start()
# Blocks while non available.
time.sleep(0.05)
- self.assertEquals(deepcopy(c3), 'Not yet got')
-
+ c3 = q.get_nowait()
+ self.assertEquals(c3, 'Not yet got')
+
# Then got when available.
pool.release(c1)
time.sleep(0.05)
- self.assertEquals(c1, q.get_nowait())
+ c3 = q.get_nowait()
+ self.assertEquals(c1, c3)
def test_max_connections_timeout(self):
"""Getting a connection raises ``ConnectionError`` after timeout."""