Only start responses patcher if not already activated.
This commit is contained in:
parent
56f29a0e6e
commit
ec0d808010
@ -172,21 +172,26 @@ class CallbackResponse(responses.CallbackResponse):
|
|||||||
|
|
||||||
|
|
||||||
botocore_mock = responses.RequestsMock(assert_all_requests_are_fired=False, target='botocore.vendored.requests.adapters.HTTPAdapter.send')
|
botocore_mock = responses.RequestsMock(assert_all_requests_are_fired=False, target='botocore.vendored.requests.adapters.HTTPAdapter.send')
|
||||||
|
responses_mock = responses._default_mock
|
||||||
|
|
||||||
|
|
||||||
class ResponsesMockAWS(BaseMockAWS):
|
class ResponsesMockAWS(BaseMockAWS):
|
||||||
def reset(self):
|
def reset(self):
|
||||||
botocore_mock.reset()
|
botocore_mock.reset()
|
||||||
responses.reset()
|
responses_mock.reset()
|
||||||
|
|
||||||
def enable_patching(self):
|
def enable_patching(self):
|
||||||
botocore_mock.start()
|
if not hasattr(botocore_mock, '_patcher') or not hasattr(botocore_mock._patcher, 'target'):
|
||||||
responses.start()
|
# Check for unactivated patcher
|
||||||
|
botocore_mock.start()
|
||||||
|
|
||||||
|
if not hasattr(responses_mock, '_patcher') or not hasattr(responses_mock._patcher, 'target'):
|
||||||
|
responses_mock.start()
|
||||||
|
|
||||||
for method in RESPONSES_METHODS:
|
for method in RESPONSES_METHODS:
|
||||||
for backend in self.backends_for_urls.values():
|
for backend in self.backends_for_urls.values():
|
||||||
for key, value in backend.urls.items():
|
for key, value in backend.urls.items():
|
||||||
responses.add(
|
responses_mock.add(
|
||||||
CallbackResponse(
|
CallbackResponse(
|
||||||
method=method,
|
method=method,
|
||||||
url=re.compile(key),
|
url=re.compile(key),
|
||||||
@ -212,7 +217,7 @@ class ResponsesMockAWS(BaseMockAWS):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
responses.stop()
|
responses_mock.stop()
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user