aboutsummaryrefslogtreecommitdiff
path: root/test/test_poolmanager.py
diff options
context:
space:
mode:
authorSVN-Git Migration <python-modules-team@lists.alioth.debian.org>2015-10-08 13:19:30 -0700
committerSVN-Git Migration <python-modules-team@lists.alioth.debian.org>2015-10-08 13:19:30 -0700
commit0c183b9d52b45bac22a2ff9db0e6348b655f4ab2 (patch)
treeffddde52af2caca5d039f3c9f185694f394a39de /test/test_poolmanager.py
downloadpython-urllib3-0c183b9d52b45bac22a2ff9db0e6348b655f4ab2.tar
python-urllib3-0c183b9d52b45bac22a2ff9db0e6348b655f4ab2.tar.gz
Imported Upstream version 1.2.2
Diffstat (limited to 'test/test_poolmanager.py')
-rw-r--r--test/test_poolmanager.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/test_poolmanager.py b/test/test_poolmanager.py
new file mode 100644
index 0000000..12722f7
--- /dev/null
+++ b/test/test_poolmanager.py
@@ -0,0 +1,47 @@
+import unittest
+
+from urllib3.poolmanager import PoolManager
+from urllib3 import connection_from_url
+
+
+class TestPoolManager(unittest.TestCase):
+ def test_same_url(self):
+ # Convince ourselves that normally we don't get the same object
+ conn1 = connection_from_url('http://localhost:8081/foo')
+ conn2 = connection_from_url('http://localhost:8081/bar')
+
+ self.assertNotEqual(conn1, conn2)
+
+ # Now try again using the PoolManager
+ p = PoolManager(1)
+
+ conn1 = p.connection_from_url('http://localhost:8081/foo')
+ conn2 = p.connection_from_url('http://localhost:8081/bar')
+
+ self.assertEqual(conn1, conn2)
+
+ def test_many_urls(self):
+ urls = [
+ "http://localhost:8081/foo",
+ "http://www.google.com/mail",
+ "http://localhost:8081/bar",
+ "https://www.google.com/",
+ "https://www.google.com/mail",
+ "http://yahoo.com",
+ "http://bing.com",
+ "http://yahoo.com/",
+ ]
+
+ connections = set()
+
+ p = PoolManager(10)
+
+ for url in urls:
+ conn = p.connection_from_url(url)
+ connections.add(conn)
+
+ self.assertEqual(len(connections), 5)
+
+
+if __name__ == '__main__':
+ unittest.main()