Update test_connect_timeout in test_networking.py

pull/9906/head
coletdjnz 2 weeks ago
parent 7886ff18dd
commit 447fb607d9
No known key found for this signature in database
GPG Key ID: 91984263BB39894A

@ -523,20 +523,17 @@ class TestHTTPRequestHandler(TestRequestHandlerBase):
def test_connect_timeout(self, handler):
# nothing should be listening on this port
connect_timeout_url = 'http://10.255.255.255'
with handler(timeout=0.01) as rh:
with handler(timeout=0.01) as rh, pytest.raises(TransportError):
now = time.time()
with pytest.raises(TransportError):
validate_and_send(
rh, Request(connect_timeout_url))
assert time.time() - now < DEFAULT_TIMEOUT
validate_and_send(rh, Request(connect_timeout_url))
assert time.time() - now < DEFAULT_TIMEOUT
with handler() as rh:
with pytest.raises(TransportError):
# Per request timeout, should override handler timeout
now = time.time()
validate_and_send(
rh, Request(connect_timeout_url, extensions={'timeout': 0.01}))
assert time.time() - now < DEFAULT_TIMEOUT
# Per request timeout, should override handler timeout
request = Request(connect_timeout_url, extensions={'timeout': 0.01})
with handler() as rh, pytest.raises(TransportError):
now = time.time()
validate_and_send(rh, request)
assert time.time() - now < DEFAULT_TIMEOUT
def test_source_address(self, handler):
source_address = f'127.0.0.{random.randint(5, 255)}'

Loading…
Cancel
Save