diff --git a/moto/core/models.py b/moto/core/models.py index c0ae85eb9..197670278 100644 --- a/moto/core/models.py +++ b/moto/core/models.py @@ -173,7 +173,7 @@ class BaseMockAWS: # Special case for UnitTests-class is_test_method = attr.startswith(unittest.TestLoader.testMethodPrefix) should_reset = False - if attr == "setUp": + if attr in ["setUp", "setup_method"]: should_reset = True elif not has_setup_method and is_test_method: should_reset = True diff --git a/tests/test_core/test_decorator_calls.py b/tests/test_core/test_decorator_calls.py index 0190a44f1..2e202f364 100644 --- a/tests/test_core/test_decorator_calls.py +++ b/tests/test_core/test_decorator_calls.py @@ -5,7 +5,7 @@ import sure # noqa # pylint: disable=unused-import import unittest from botocore.exceptions import ClientError -from moto import mock_ec2, mock_s3, settings +from moto import mock_ec2, mock_kinesis, mock_s3, settings from unittest import SkipTest """ @@ -159,6 +159,25 @@ class TestWithSetupMethod: s3.head_bucket(Bucket="unknown_bucket") +@mock_kinesis +class TestKinesisUsingSetupMethod: + def setup_method(self, *args): + self.stream_name = "test_stream" + self.boto3_kinesis_client = boto3.client("kinesis", region_name="us-east-1") + self.boto3_kinesis_client.create_stream( + StreamName=self.stream_name, ShardCount=1 + ) + + def test_stream_creation(self): + pass + + def test_stream_recreation(self): + # The setup-method will run again for this test + # The fact that it passes, means the state was reset + # Otherwise it would complain about a stream already existing + pass + + @mock_s3 class TestWithInvalidSetupMethod: def setupmethod(self):