Skip to content

Commit 00cb859

Browse files
committed
Switch to the moto v5 API
1 parent a857584 commit 00cb859

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

tests/test_s3.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,16 @@
2424
try:
2525
import boto3
2626
import botocore
27-
from moto import mock_s3
27+
28+
try:
29+
from moto import mock_aws # v5
30+
except ImportError:
31+
from moto import mock_s3 as mock_aws
2832
except ImportError:
2933
boto3 = None
3034

31-
def mock_s3(cls):
32-
"""No-op decorator in case moto mock_s3 can not be imported."""
35+
def mock_aws(cls):
36+
"""No-op decorator in case moto mock_aws can not be imported."""
3337
return cls
3438

3539

@@ -47,13 +51,13 @@ class S3ReadWriteTestCase(GenericReadWriteTestCase, unittest.TestCase):
4751
scheme = "s3"
4852
netloc = "my_2nd_bucket"
4953

50-
mock_s3 = mock_s3()
54+
mock_aws = mock_aws()
5155
"""The mocked s3 interface from moto."""
5256

5357
def setUp(self):
5458
self.enterContext(clean_test_environment_for_s3())
5559
# Enable S3 mocking of tests.
56-
self.mock_s3.start()
60+
self.mock_aws.start()
5761

5862
# MOTO needs to know that we expect Bucket bucketname to exist
5963
s3 = boto3.resource("s3")
@@ -77,7 +81,7 @@ def tearDown(self):
7781
bucket.delete()
7882

7983
# Stop the S3 mock.
80-
self.mock_s3.stop()
84+
self.mock_aws.stop()
8185

8286
S3ResourcePath.use_threads = None
8387

tests/test_s3utils.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@
2626
try:
2727
import boto3
2828
from botocore.exceptions import ParamValidationError
29-
from moto import mock_s3
29+
30+
try:
31+
from moto import mock_aws # v5
32+
except ImportError:
33+
from moto import mock_s3 as mock_aws
3034
except ImportError:
3135
boto3 = None
3236

@@ -44,7 +48,7 @@ class S3UtilsTestCase(unittest.TestCase):
4448

4549
def setUp(self):
4650
self.enterContext(clean_test_environment_for_s3())
47-
self.enterContext(mock_s3())
51+
self.enterContext(mock_aws())
4852

4953
self.client = getS3Client()
5054
try:

0 commit comments

Comments
 (0)