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:
Anders Kaseorg 2021-01-15 01:12:41 -08:00 committed by GitHub
commit 8befcb6a48
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 7 deletions

View file

@ -8,9 +8,9 @@ import requests
import sure # noqa
from botocore.exceptions import ClientError
import responses
from moto import mock_apigateway, mock_cognitoidp, settings
from moto.core import ACCOUNT_ID
from moto.core.models import responses_mock
import pytest
@ -1786,8 +1786,8 @@ def test_get_model_with_invalid_name():
@mock_apigateway
def test_http_proxying_integration():
responses.add(
responses.GET, "http://httpbin.org/robots.txt", body="a fake response"
responses_mock.add(
responses_mock.GET, "http://httpbin.org/robots.txt", body="a fake response"
)
region_name = "us-west-2"

View file

@ -8,11 +8,11 @@ import re
from freezegun import freeze_time
import sure # noqa
import responses
from botocore.exceptions import ClientError
import pytest
from moto import mock_sns, mock_sqs, settings
from moto.core import ACCOUNT_ID
from moto.core.models import responses_mock
from moto.sns import sns_backend
MESSAGE_FROM_SQS_TEMPLATE = (
@ -332,7 +332,7 @@ def test_publish_to_http():
json.loads.when.called_with(request.body.decode()).should_not.throw(Exception)
return 200, {}, ""
responses.add_callback(
responses_mock.add_callback(
method="POST", url="http://example.com/foobar", callback=callback
)