Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuration of passthrough during BaseResponse construction #558

Merged
merged 9 commits into from
Jun 13, 2022
16 changes: 11 additions & 5 deletions responses/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,8 @@ def __init__(
url: _URLPatternType,
match_querystring: Union[bool, object] = None,
match: "_MatcherIterable" = (),
*args: Any,
**kwargs: Any,
*,
passthrough: bool = False,
jayaddison marked this conversation as resolved.
Show resolved Hide resolved
) -> None:
self.method: str = method
# ensure the url has a default path set if the url is a string
Expand All @@ -368,8 +368,7 @@ def __init__(

self.match: "_MatcherIterable" = match
self.call_count: int = 0
if "passthrough" in kwargs:
self.passthrough = kwargs["passthrough"]
self.passthrough = passthrough

def __eq__(self, other: Any) -> bool:
if not isinstance(other, BaseResponse):
Expand Down Expand Up @@ -600,7 +599,14 @@ def get_response(self, request: "PreparedRequest") -> HTTPResponse:


class PassthroughResponse(BaseResponse):
passthrough: bool = True
def __init__(
self,
method: str,
url: _URLPatternType,
match_querystring: Union[bool, object] = None,
match: "_MatcherIterable" = (),
):
super().__init__(method, url, match_querystring, match, passthrough=True)
jayaddison marked this conversation as resolved.
Show resolved Hide resolved


class OriginalResponseShim(object):
Expand Down