aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_poolmanager.py8
-rw-r--r--test/test_util.py6
2 files changed, 11 insertions, 3 deletions
diff --git a/test/test_poolmanager.py b/test/test_poolmanager.py
index 2faab94..759b5e3 100644
--- a/test/test_poolmanager.py
+++ b/test/test_poolmanager.py
@@ -2,7 +2,10 @@ import unittest
from urllib3.poolmanager import PoolManager
from urllib3 import connection_from_url
-from urllib3.exceptions import ClosedPoolError
+from urllib3.exceptions import (
+ ClosedPoolError,
+ LocationParseError,
+)
class TestPoolManager(unittest.TestCase):
@@ -63,6 +66,9 @@ class TestPoolManager(unittest.TestCase):
self.assertEqual(len(p.pools), 0)
+ def test_nohost(self):
+ p = PoolManager(5)
+ self.assertRaises(LocationParseError, p.connection_from_url, 'http://@')
if __name__ == '__main__':
diff --git a/test/test_util.py b/test/test_util.py
index ebd3b5f..5dcaeab 100644
--- a/test/test_util.py
+++ b/test/test_util.py
@@ -77,6 +77,7 @@ class TestUtil(unittest.TestCase):
for location in invalid_host:
self.assertRaises(LocationParseError, get_host, location)
+
def test_parse_url(self):
url_host_map = {
'http://google.com/mail': Url('http', host='google.com', path='/mail'),
@@ -107,6 +108,7 @@ class TestUtil(unittest.TestCase):
'http://foo:bar@localhost/': Url('http', auth='foo:bar', host='localhost', path='/'),
'http://foo@localhost/': Url('http', auth='foo', host='localhost', path='/'),
'http://foo:bar@baz@localhost/': Url('http', auth='foo:bar@baz', host='localhost', path='/'),
+ 'http://@': Url('http', host=None, auth='')
}
for url, expected_url in url_host_map.items():
returned_url = parse_url(url)
@@ -231,7 +233,7 @@ class TestUtil(unittest.TestCase):
self.assertTrue('int or float' in str(e))
- @patch('urllib3.util.current_time')
+ @patch('urllib3.util.timeout.current_time')
def test_timeout(self, current_time):
timeout = Timeout(total=3)
@@ -278,7 +280,7 @@ class TestUtil(unittest.TestCase):
self.assertEqual(str(timeout), "Timeout(connect=1, read=None, total=3)")
- @patch('urllib3.util.current_time')
+ @patch('urllib3.util.timeout.current_time')
def test_timeout_elapsed(self, current_time):
current_time.return_value = TIMEOUT_EPOCH
timeout = Timeout(total=3)