Leave the global responses configuration alone (#3529)
Instead of modifying responses._default_mock, create our own responses.RequestsMock object that we can modify as needed without interfering with other users of the responses library. Fixes #3264. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
parent
c8151e1bb4
commit
8befcb6a48
4 changed files with 8 additions and 7 deletions
|
|
@ -41,6 +41,7 @@ from .exceptions import (
|
|||
RestAPINotFound,
|
||||
ModelNotFound,
|
||||
)
|
||||
from ..core.models import responses_mock
|
||||
|
||||
STAGE_URL = "https://{api_id}.execute-api.{region_name}.amazonaws.com/{stage_name}"
|
||||
|
||||
|
|
@ -565,7 +566,7 @@ class RestAPI(BaseModel):
|
|||
)
|
||||
|
||||
for url in [stage_url_lower, stage_url_upper]:
|
||||
responses._default_mock._matches.insert(
|
||||
responses_mock._matches.insert(
|
||||
0,
|
||||
responses.CallbackResponse(
|
||||
url=url,
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ botocore_mock = responses.RequestsMock(
|
|||
target="botocore.vendored.requests.adapters.HTTPAdapter.send",
|
||||
)
|
||||
|
||||
responses_mock = responses._default_mock
|
||||
responses_mock = responses.RequestsMock(assert_all_requests_are_fired=False)
|
||||
# Add passthrough to allow any other requests to work
|
||||
# Since this uses .startswith, it applies to http and https requests.
|
||||
responses_mock.add_passthru("http")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue