Add test for ConnectionPool.close
Fix pool test close twice
@@ -249,6 +249,23 @@ class TestConnectionPool(object):
with pytest.raises(Empty):
old_pool_queue.get(block=False)
+ def test_pool_close_twice(self):
+ pool = connection_from_url('http://google.com:80')
+
+ # Populate with some connections
+ conn1 = pool._get_conn()
+ conn2 = pool._get_conn()
+ pool._put_conn(conn1)
+ pool._put_conn(conn2)
+
+ pool.close()
+ assert pool.pool is None
+
+ try:
+ pool.close()
+ except AttributeError:
+ pytest.fail("Pool of the ConnectionPool is None and has no attribute get.")
+
def test_pool_timeouts(self):
with HTTPConnectionPool(host='localhost') as pool:
conn = pool._new_conn()
