`Response.elapsed` not set
Closed this issue · 1 comments
stefanadelbert commented
Problem
Response.elapsed
isn't set after a mocked POST if add_response
is given json=...
or content=b...
.
Reproduce
This snippet replicates the problem for me:
def test_elapsed(httpx_mock: HTTPXMock):
httpx_mock.add_response(json={})
r = httpx.post(
"https://jsonplaceholder.typicode.com/posts",
data={"title": "foo", "body": "bar", "userId": 1,},
headers={"Content-type": "application/json; charset=UTF-8"},
)
r.raise_for_status()
r.close()
print(r.elapsed.total_seconds())
Versions
httpx=0.21.3
pytest_httpx=0.15.0
Colin-b commented
Hello @stefanadelbert ,
Please upgrade your version of pytest-httpx to the latest one, this was fixed in the 0.17 series.