From 1773e973786701a6f60f08514e55ec625062ad35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Ba=C5=A1ista?= Date: Wed, 17 Apr 2024 12:46:14 +0200 Subject: [PATCH] Stubs: Mock httpx.Reponse.elapsed with a constant This is a naive way of working around the issue where `httpx.Response.elapsed` property is unavailable in tests that use vcrpy because the httpx responses built from serialized data by vcrpy currently lack the `elapsed` property. --- vcr/stubs/httpx_stubs.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vcr/stubs/httpx_stubs.py b/vcr/stubs/httpx_stubs.py index 759cb727..b9fd59f9 100644 --- a/vcr/stubs/httpx_stubs.py +++ b/vcr/stubs/httpx_stubs.py @@ -1,4 +1,5 @@ import asyncio +from datetime import timedelta import functools import inspect import logging @@ -100,6 +101,7 @@ def _from_serialized_response(request, serialized_response, history=None): history=history or [], extensions=extensions, ) + response.elapsed = timedelta(seconds=1) return response