Patched version that ensures response._content is properly set.
(
request: Any, serialized_response: Any, history: Any = None
)
| 171 | _from_serialized: Any = _original_from_serialized_response |
| 172 | |
| 173 | def _patched_from_serialized_response( |
| 174 | request: Any, serialized_response: Any, history: Any = None |
| 175 | ) -> Any: |
| 176 | """Patched version that ensures response._content is properly set.""" |
| 177 | response = _from_serialized(request, serialized_response, history) |
| 178 | # Explicitly set _content to avoid ResponseNotRead errors |
| 179 | # The content was passed to the constructor but the mocked read() prevents |
| 180 | # proper initialization of the internal state |
| 181 | body_content = serialized_response.get("body", {}).get("string", b"") |
| 182 | if isinstance(body_content, str): |
| 183 | body_content = body_content.encode("utf-8") |
| 184 | response._content = body_content |
| 185 | return response |
| 186 | |
| 187 | httpx_stubs._from_serialized_response = _patched_from_serialized_response |
| 188 |
nothing calls this directly
no test coverage detected
searching dependent graphs…