Open
Description
Hi, thanks for the great project! There's one thing that keeps tripping me up and that's when I want to return multiple responses after each request. For example, to exercise retries.
Currently I'm using the following pattern:
resps = [...]
def respond(req):
return resps.pop(0)
httpserver.expect_request("/").respond_with_handler(
respond
)
Which can be generalized to:
@attrs.define
class MultipleResponsesHandler:
_responses: list[Response]
def __call__(self, _):
return self._responses.pop(0)
httpserver.expect_request("/").respond_with_handler(
MultipleResponsesHandler(...)
)
Is there a more elegant way to achieve this and/or should this be part of pytest-httpserver?
Metadata
Metadata
Assignees
Labels
No labels