]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Fix flaky Response.elapsed tests (#446)
authorFlorimond Manca <florimond.manca@gmail.com>
Fri, 4 Oct 2019 20:36:06 +0000 (22:36 +0200)
committerSeth Michael Larson <sethmichaellarson@gmail.com>
Fri, 4 Oct 2019 20:36:06 +0000 (15:36 -0500)
tests/client/test_client.py

index 4cca746db6a74dd69f3587cf2e805487600c25e0..f7be6070e916132c294bae8a01b82f2a377c1fca 100644 (file)
@@ -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)