Skip to content
Myr

Trivial-case test for response.elapsed

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

authored by Tom Christie · committed by Tom Christie · parent 3124a38 · Browse files · 1 file+1 added−13 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+1 added−13 removed

  • tests:+1 added−13 removed

1 file+1 added−13 removed

modified:tests/client/test_client.py+1 added-13 removed
1from datetime import timedelta2from time import sleep23import pytest45import httpx
172 unmodified lines
178async def test_elapsed_delay(server):179 url = server.url.copy_with(path="/slow_response/100")180 async with httpx.Client() as client:181 response = await client.get(url)183 assert response.elapsed.total_seconds() == pytest.approx(0.1, rel=0.2)184185186@pytest.mark.asyncio187async def test_elapsed_delay_ignores_read_time(server):188 url = server.url.copy_with(path="/slow_response/100")189 async with httpx.Client() as client:190 async with client.stream("GET", url) as response:191 sleep(0.2)192 await response.read()193194 assert response.elapsed.total_seconds() == pytest.approx(0.1, rel=0.2)182 assert response.elapsed.total_seconds() > 0.0