diff options
author | SVN-Git Migration <python-modules-team@lists.alioth.debian.org> | 2015-10-08 13:19:42 -0700 |
---|---|---|
committer | SVN-Git Migration <python-modules-team@lists.alioth.debian.org> | 2015-10-08 13:19:42 -0700 |
commit | c9df3d807f7134f58f4a84dc8b80e9dc98c62f3a (patch) | |
tree | 2c14ecbc5e10513419b15f690e7bddfdb2dab75e /test/test_connectionpool.py | |
parent | b6ab7bae87b22c6fae783e8850533219d3bf8a29 (diff) | |
download | python-urllib3-c9df3d807f7134f58f4a84dc8b80e9dc98c62f3a.tar python-urllib3-c9df3d807f7134f58f4a84dc8b80e9dc98c62f3a.tar.gz |
Imported Upstream version 1.10.4
Diffstat (limited to 'test/test_connectionpool.py')
-rw-r--r-- | test/test_connectionpool.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/test_connectionpool.py b/test/test_connectionpool.py index a6dbcf4..0718b0f 100644 --- a/test/test_connectionpool.py +++ b/test/test_connectionpool.py @@ -205,6 +205,26 @@ class TestConnectionPool(unittest.TestCase): def test_no_host(self): self.assertRaises(LocationValueError, HTTPConnectionPool, None) + def test_contextmanager(self): + with connection_from_url('http://google.com:80') as pool: + # Populate with some connections + conn1 = pool._get_conn() + conn2 = pool._get_conn() + conn3 = pool._get_conn() + pool._put_conn(conn1) + pool._put_conn(conn2) + + old_pool_queue = pool.pool + + self.assertEqual(pool.pool, None) + + self.assertRaises(ClosedPoolError, pool._get_conn) + + pool._put_conn(conn3) + + self.assertRaises(ClosedPoolError, pool._get_conn) + + self.assertRaises(Empty, old_pool_queue.get, block=False) if __name__ == '__main__': |