You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When building an httpx response at vcr.stubs.httpx_stubs._from_serialized_response, the elapsed property was not covered. This cause tests to break as the elapsed property is dynamic calculated and depends on the patched method close.
# test_script.pyimportpytestimportvcr@vcr.use_cassete("cassete.yml")@pytest.mark.asynciodeftest_get_elapsed_microsecs():
''' Breaks raising ".elapsed may ony be accessed after the response has been read or closed" '''microsecs=get_elapsed_microsecs()
assertmicrosecs>=0.02
The text was updated successfully, but these errors were encountered:
Unfortunately, even the latest release v6.0.1 of vcrpy does not seem to resolve this issue. From my experiments it looks like httpx.Response.elapsed still cannot be accessed in tests.
As was mentioned in the original message by @isaquealves from almost 3 years ago, the problem is that the httpx.Response.elapsed property is only being set by the httpx.Response.close method which is being mocked while creating a response from serialized data in vcr.stubs.httpx_stubs._from_serialized_response function. And since there is no additional patching done by vcrpy, this property remains unavailable.
When building an
httpx
response atvcr.stubs.httpx_stubs._from_serialized_response
, the elapsed property was not covered. This cause tests to break as the elapsed property is dynamic calculated and depends on the patched methodclose
.Example:
The text was updated successfully, but these errors were encountered: