summaryrefslogtreecommitdiff
path: root/test/engine/test_pool.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2016-06-15 18:15:46 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2016-06-15 18:15:46 -0400
commite5bdf96bc0b1503c4e4c8461748cd061f624e346 (patch)
tree7886ba1901bfc5756a60bffae8ad090a340a9d69 /test/engine/test_pool.py
parent345cc1e304f3dc75bf5362e6c9f1975230a94753 (diff)
downloadsqlalchemy-e5bdf96bc0b1503c4e4c8461748cd061f624e346.tar.gz
- dont use id() to test identity as these can be recycled
Change-Id: Ie4cb4924909d55c5962f66e36cd5325e8e8f0538
Diffstat (limited to 'test/engine/test_pool.py')
-rw-r--r--test/engine/test_pool.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/test/engine/test_pool.py b/test/engine/test_pool.py
index a4f891b3c..057289199 100644
--- a/test/engine/test_pool.py
+++ b/test/engine/test_pool.py
@@ -1455,16 +1455,17 @@ class QueuePoolTest(PoolTestBase):
max_overflow=0,
recycle=30)
c1 = p.connect()
- c_id = id(c1.connection)
+ c_ref = weakref.ref(c1.connection)
c1.close()
mock.return_value = 10001
c2 = p.connect()
- assert id(c2.connection) == c_id
+
+ is_(c2.connection, c_ref())
c2.close()
mock.return_value = 10035
c3 = p.connect()
- assert id(c3.connection) != c_id
+ is_not_(c3.connection, c_ref())
@testing.requires.timing_intensive
def test_recycle_on_invalidate(self):
@@ -1472,10 +1473,10 @@ class QueuePoolTest(PoolTestBase):
pool_size=1,
max_overflow=0)
c1 = p.connect()
- c_id = id(c1.connection)
+ c_ref = weakref.ref(c1.connection)
c1.close()
c2 = p.connect()
- assert id(c2.connection) == c_id
+ is_(c2.connection, c_ref())
c2_rec = c2._connection_record
p._invalidate(c2)
@@ -1483,7 +1484,8 @@ class QueuePoolTest(PoolTestBase):
c2.close()
time.sleep(.5)
c3 = p.connect()
- assert id(c3.connection) != c_id
+
+ is_not_(c3.connection, c_ref())
@testing.requires.timing_intensive
def test_recycle_on_soft_invalidate(self):
@@ -1491,21 +1493,21 @@ class QueuePoolTest(PoolTestBase):
pool_size=1,
max_overflow=0)
c1 = p.connect()
- c_id = id(c1.connection)
+ c_ref = weakref.ref(c1.connection)
c1.close()
c2 = p.connect()
- assert id(c2.connection) == c_id
+ is_(c2.connection, c_ref())
c2_rec = c2._connection_record
c2.invalidate(soft=True)
- assert c2_rec.connection is c2.connection
+ is_(c2_rec.connection, c2.connection)
c2.close()
time.sleep(.5)
c3 = p.connect()
- assert id(c3.connection) != c_id
- assert c3._connection_record is c2_rec
- assert c2_rec.connection is c3.connection
+ is_not_(c3.connection, c_ref())
+ is_(c3._connection_record, c2_rec)
+ is_(c2_rec.connection, c3.connection)
def _no_wr_finalize(self):
finalize_fairy = pool._finalize_fairy