A response body that fails with `error` after its first chunk.
| 220 | |
| 221 | |
| 222 | class 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 | |
| 240 | Request = Callable[..., Stream[object]] |
no outgoing calls