From 586acddd1a72e69e61d02af084a86cb51168e8cb Mon Sep 17 00:00:00 2001 From: Florimond Manca Date: Fri, 8 Nov 2019 00:35:34 +0100 Subject: [PATCH] Improve robustness of live HTTP/2 test (#512) --- tests/dispatch/test_http2.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/dispatch/test_http2.py b/tests/dispatch/test_http2.py index e7ee68ef4c..b6262c6142 100644 --- a/tests/dispatch/test_http2.py +++ b/tests/dispatch/test_http2.py @@ -1,10 +1,12 @@ import json +import socket import h2.connection import h2.events +import pytest from h2.settings import SettingCodes -from httpx import AsyncClient, Client, Response +from httpx import AsyncClient, Client, Response, Timeout from .utils import MockHTTP2Backend @@ -208,7 +210,11 @@ async def test_http2_settings_in_handshake(backend): async def test_http2_live_request(backend): async with AsyncClient(backend=backend) as client: - resp = await client.get("https://nghttp2.org/httpbin/anything") - + try: + resp = await client.get("https://nghttp2.org/httpbin/anything") + except Timeout: + pytest.xfail(reason="nghttp2.org appears to be unresponsive") + except socket.gaierror: + pytest.xfail(reason="You appear to be offline") assert resp.status_code == 200 assert resp.http_version == "HTTP/2"