MCPcopy Create free account
hub / github.com/anthropics/anthropic-sdk-python / FailingBody

Class FailingBody

tests/utils.py:222–237  ·  view source on GitHub ↗

A response body that fails with `error` after its first chunk.

Source from the content-addressed store, hash-verified

220
221
222class FailingBody(Body):
223 """A response body that fails with `error` after its first chunk."""
224
225 def __init__(self, error: Exception) -> None:
226 super().__init__()
227 self.error = error
228
229 @override
230 def __iter__(self) -> Iterator[bytes]:
231 yield self.chunks[0]
232 raise self.error
233
234 @override
235 async def __aiter__(self) -> AsyncIterator[bytes]:
236 yield self.chunks[0]
237 raise self.error
238
239
240Request = Callable[..., Stream[object]]

Calls

no outgoing calls