Cleanup model ref resetting.
This commit is contained in:
parent
308712841c
commit
b19c201975
@ -466,10 +466,14 @@ class BaseModel(object):
|
||||
|
||||
class BaseBackend(object):
|
||||
|
||||
def reset(self):
|
||||
def _reset_model_refs(self):
|
||||
# Remove all references to the models stored
|
||||
for service, models in model_data.items():
|
||||
for model_name, model in models.items():
|
||||
model.instances = []
|
||||
|
||||
def reset(self):
|
||||
self._reset_model_refs()
|
||||
self.__dict__ = {}
|
||||
self.__init__()
|
||||
|
||||
|
@ -379,6 +379,7 @@ class SQSBackend(BaseBackend):
|
||||
|
||||
def reset(self):
|
||||
region_name = self.region_name
|
||||
self._reset_model_refs()
|
||||
self.__dict__ = {}
|
||||
self.__init__(region_name)
|
||||
|
||||
|
@ -2,7 +2,7 @@ import sure # noqa
|
||||
import boto3
|
||||
from moto import mock_sqs
|
||||
|
||||
def test_reset_api():
|
||||
def test_context_manager_returns_mock():
|
||||
with mock_sqs() as sqs_mock:
|
||||
conn = boto3.client("sqs", region_name='us-west-1')
|
||||
conn.create_queue(QueueName="queue1")
|
||||
|
Loading…
Reference in New Issue
Block a user