kevin1024 / vcrpy

Automatically mock your HTTP interactions to simplify and speed up testing
MIT License
2.72k stars 388 forks source link

Httpx Response content is not set/read, causing JSON parsing errors #834

Open Yun-Kim opened 7 months ago

Yun-Kim commented 7 months ago

Hi there, running into the same issue as #832. It seems like getting rid of the manual step to set response._content, as well as mocking the httpx.Response.read() function resulted in the following error by httpx (occurs non-deterministically in my CI):

httpx.ResponseNotRead: Attempted to access streaming response content, without having called `read()` 

I haven't narrowed down the non-deterministic nature of this bug, but it seems like there's two solutions to this:

  1. Re-insert the manual step to set response._content that was removed by https://github.com/kevin1024/vcrpy/pull/649
  2. Don't patch httpx.Response.read (not sure what the implications of this is)

This is causing a good amount of flakiness in my CI, so would really appreciate any insights/help getting this fixed. Thanks!