diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-06-02 18:40:46 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-06-02 18:40:46 -0400 |
commit | 74ca7f627ea8f31a8312f965d5249ce1f701d627 (patch) | |
tree | 48038f6acf86cbf75898cb837fbd9b6785a31610 | |
parent | 59d90c95a133ee6b4a4db8ed61c699956eb33e9f (diff) | |
download | sqlalchemy-74ca7f627ea8f31a8312f965d5249ce1f701d627.tar.gz |
- use a mock here, do away with timing problems for good. need to do this
for the rest of the timing tests
Change-Id: I06a815b1500222126a4dbc2a9a5da3ef7847e321
-rw-r--r-- | test/engine/test_pool.py | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/test/engine/test_pool.py b/test/engine/test_pool.py index 4547984ab..4f804f8b2 100644 --- a/test/engine/test_pool.py +++ b/test/engine/test_pool.py @@ -1433,18 +1433,24 @@ class QueuePoolTest(PoolTestBase): self.assert_(p.checkedout() == 0) def test_recycle(self): - p = self._queuepool_fixture(pool_size=1, - max_overflow=0, - recycle=3) - c1 = p.connect() - c_id = id(c1.connection) - c1.close() - c2 = p.connect() - assert id(c2.connection) == c_id - c2.close() - time.sleep(4) - c3 = p.connect() - assert id(c3.connection) != c_id + with patch("sqlalchemy.pool.time.time") as mock: + mock.return_value = 10000 + + p = self._queuepool_fixture( + pool_size=1, + max_overflow=0, + recycle=30) + c1 = p.connect() + c_id = id(c1.connection) + c1.close() + mock.return_value = 10001 + c2 = p.connect() + assert id(c2.connection) == c_id + c2.close() + + mock.return_value = 10035 + c3 = p.connect() + assert id(c3.connection) != c_id @testing.requires.timing_intensive def test_recycle_on_invalidate(self): |