Test for throwing useful exception on bad label.
authorCory Benfield <lukasaoz@gmail.com>
Fri, 10 Aug 2012 16:24:00 +0000 (17:24 +0100)
committerCory Benfield <lukasaoz@gmail.com>
Mon, 13 Aug 2012 20:18:56 +0000 (21:18 +0100)
tests/test_requests.py

index f43ccac85b021c9fd5ac5adf2bac1481c954a65f..3bbcfdf48e4e2e7e174a899c49e9cb04bddb4ec8 100755 (executable)
@@ -19,6 +19,7 @@ from requests.compat import str, StringIO
 from requests import HTTPError
 from requests import get, post, head, put
 from requests.auth import HTTPBasicAuth, HTTPDigestAuth
+from requests.exceptions import InvalidURL
 
 if 'HTTPBIN_URL' not in os.environ:
     os.environ['HTTPBIN_URL'] = 'http://httpbin.org/'
@@ -1062,6 +1063,10 @@ class RequestsTestSuite(TestSetup, TestBaseMixin, unittest.TestCase):
         """Test that `bytes` can be used as the values of `files`."""
         post(httpbin('post'), files={'test': b'test'})
 
+    def test_invalid_urls_throw_requests_exception(self):
+        """Test that URLs with invalid labels throw
+        Requests.exceptions.InvalidURL instead of UnicodeError."""
+        self.assertRaises(InvalidURL, get, 'http://.google.com/')
 
 if __name__ == '__main__':
     unittest.main()