From: Florimond Manca Date: Fri, 4 Oct 2019 20:36:06 +0000 (+0200) Subject: Fix flaky Response.elapsed tests (#446) X-Git-Tag: 0.7.5~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=24346e20396ee0aba976d8056f21a4182e683b13;p=thirdparty%2Fhttpx.git Fix flaky Response.elapsed tests (#446) --- diff --git a/tests/client/test_client.py b/tests/client/test_client.py index 4cca746d..f7be6070 100644 --- a/tests/client/test_client.py +++ b/tests/client/test_client.py @@ -165,12 +165,14 @@ def test_client_backend_must_be_asyncio_based(): def test_elapsed_delay(server): with httpx.Client() as http: response = http.get(server.url.copy_with(path="/slow_response/100")) - assert response.elapsed.total_seconds() == pytest.approx(0.1, abs=0.01) + assert response.elapsed.total_seconds() == pytest.approx(0.1, rel=0.2) def test_elapsed_delay_ignores_read_time(server): with httpx.Client() as http: - response = http.get(server.url.copy_with(path="/slow_response/50"), stream=True) - sleep(0.1) + response = http.get( + server.url.copy_with(path="/slow_response/100"), stream=True + ) + sleep(0.2) response.read() - assert response.elapsed.total_seconds() == pytest.approx(0.05, abs=0.01) + assert response.elapsed.total_seconds() == pytest.approx(0.1, rel=0.2)