Py3: use unittest.mock instead of mock (#3481)

* Py3: use unittest.mock instead of mock

* noqa

* oops

* just pull in patch()

* ignore RuntimeError when stopping patch

* ignore RuntimeError from default_session_mock.stop()
This commit is contained in:
David Baumgold 2021-04-06 11:22:42 +02:00 committed by GitHub
commit 3af87963d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 36 additions and 15 deletions

View file

@ -2,8 +2,8 @@ from __future__ import unicode_literals
import json
import yaml
from mock import patch
import sure # noqa
from tests.compat import patch
from moto.cloudformation.exceptions import ValidationError
from moto.cloudformation.models import FakeStack

View file

@ -1,7 +1,8 @@
from __future__ import unicode_literals
from mock import patch
import sure # noqa
from tests.compat import patch
from moto.server import main, create_backend_app, DomainDispatcherApplication

View file

@ -36,7 +36,10 @@ class TestCore:
self.stream_arn = None
for m in self.mocks:
m.stop()
try:
m.stop()
except RuntimeError:
pass
def test_verify_stream(self):
conn = boto3.client("dynamodb", region_name="us-east-1")
@ -200,7 +203,10 @@ class TestEdges:
def teardown(self):
for m in self.mocks:
m.stop()
try:
m.stop()
except RuntimeError:
pass
def test_enable_stream_on_table(self):
conn = boto3.client("dynamodb", region_name="us-east-1")

View file

@ -1,7 +1,6 @@
# #!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import mock
from moto.packages.httpretty.core import (
HTTPrettyRequest,

View file

@ -28,7 +28,10 @@ class TestDBInstanceFilters(object):
@classmethod
def teardown_class(cls):
cls.mock_rds.stop()
try:
cls.mock_rds.stop()
except RuntimeError:
pass
def test_invalid_filter_name_raises_error(self):
with pytest.raises(ClientError) as ex:
@ -203,7 +206,10 @@ class TestDBSnapshotFilters(object):
@classmethod
def teardown_class(cls):
cls.mock_rds.stop()
try:
cls.mock_rds.stop()
except RuntimeError:
pass
def test_invalid_filter_name_raises_error(self):
with pytest.raises(ClientError) as ex: