Skip to content
Myr

Fix flaky Response.elapsed tests (#446)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Florimond Manca · committed by Seth Michael Larson · parent b479ceb · Browse files · 1 file+6 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+6 added−4 removed

  • tests:+6 added−4 removed

1 file+6 added−4 removed

modified:tests/client/test_client.py+6 added-4 removed
163 unmodified lines
164165def test_elapsed_delay(server):166 with httpx.Client() as http:167 response = http.get(server.url.copy_with(path="/slow_response/100"))168 assert response.elapsed.total_seconds() == pytest.approx(0.1, abs=0.01)168 assert response.elapsed.total_seconds() == pytest.approx(0.1, rel=0.2)169170171def test_elapsed_delay_ignores_read_time(server):172 with httpx.Client() as http:173 response = http.get(server.url.copy_with(path="/slow_response/50"), stream=True)174 sleep(0.1)173 response = http.get(174 server.url.copy_with(path="/slow_response/100"), stream=True175 )176 sleep(0.2)177 response.read()176 assert response.elapsed.total_seconds() == pytest.approx(0.05, abs=0.01)178 assert response.elapsed.total_seconds() == pytest.approx(0.1, rel=0.2)