]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Add ConnectTimeout test
authorTom Christie <tom@tomchristie.com>
Thu, 18 Apr 2019 08:38:29 +0000 (09:38 +0100)
committerTom Christie <tom@tomchristie.com>
Thu, 18 Apr 2019 08:38:29 +0000 (09:38 +0100)
tests/test_timeouts.py

index 61ce9a18d06533af84dbaa339ae2458a2c3f547f..b1ceef93d455cc0fd0f1a5a73bcb4432c7fae006 100644 (file)
@@ -12,6 +12,16 @@ async def test_read_timeout(server):
             await http.request("GET", "http://127.0.0.1:8000/slow_response")
 
 
+@pytest.mark.asyncio
+async def test_connect_timeout(server):
+    timeout = httpcore.TimeoutConfig(connect_timeout=0.0001)
+
+    async with httpcore.ConnectionPool(timeout=timeout) as http:
+        with pytest.raises(httpcore.ConnectTimeout):
+            # See https://stackoverflow.com/questions/100841/
+            await http.request("GET", "http://10.255.255.1/")
+
+
 @pytest.mark.asyncio
 async def test_pool_timeout(server):
     timeout = httpcore.TimeoutConfig(pool_timeout=0.0001)