aboutsummaryrefslogtreecommitdiff
path: root/test/test_poolmanager.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_poolmanager.py')
-rw-r--r--test/test_poolmanager.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/test_poolmanager.py b/test/test_poolmanager.py
index 12722f7..273abf9 100644
--- a/test/test_poolmanager.py
+++ b/test/test_poolmanager.py
@@ -2,6 +2,7 @@ import unittest
from urllib3.poolmanager import PoolManager
from urllib3 import connection_from_url
+from urllib3.exceptions import ClosedPoolError
class TestPoolManager(unittest.TestCase):
@@ -42,6 +43,29 @@ class TestPoolManager(unittest.TestCase):
self.assertEqual(len(connections), 5)
+ def test_manager_clear(self):
+ p = PoolManager(5)
+
+ conn_pool = p.connection_from_url('http://google.com')
+ self.assertEqual(len(p.pools), 1)
+
+ conn = conn_pool._get_conn()
+
+ p.clear()
+ self.assertEqual(len(p.pools), 0)
+
+ with self.assertRaises(ClosedPoolError):
+ conn_pool._get_conn()
+
+ conn_pool._put_conn(conn)
+
+ with self.assertRaises(ClosedPoolError):
+ conn_pool._get_conn()
+
+ self.assertEqual(len(p.pools), 0)
+
+
+
if __name__ == '__main__':
unittest.main()