Add test that invalid domain raises a ConnectionError
authorKevin Burke <kev@inburke.com>
Fri, 29 Aug 2014 21:07:28 +0000 (14:07 -0700)
committerKevin Burke <kev@inburke.com>
Fri, 29 Aug 2014 21:07:28 +0000 (14:07 -0700)
test_requests.py

index 716c0dcff6f7c97d6786b898f08cbdefb17050e1..3868f9dc1f7da132c59d08e4aad1a81164443d64 100755 (executable)
@@ -286,6 +286,11 @@ class RequestsTestCase(unittest.TestCase):
         r = s.get(url)
         assert r.status_code == 200
 
+    def test_connection_error(self):
+        """Connecting to an unknown domain should raise a ConnectionError"""
+        with pytest.raises(ConnectionError):
+            requests.get("http://fooobarbangbazbing.httpbin.org")
+
     def test_basicauth_with_netrc(self):
         auth = ('user', 'pass')
         wrong_auth = ('wronguser', 'wrongpass')