Skip to content

Commit

Permalink
Fix import for new moto version
Browse files Browse the repository at this point in the history
Moto 5 (which supports py38+) replaces all decorators with `mock_aws`.
  • Loading branch information
chris-janidlo committed Feb 7, 2024
1 parent 6afe56b commit 04b9612
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tests/unit/test_storage.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
import uuid

import pytest
Expand All @@ -12,7 +13,12 @@

try:
import boto3
from moto import mock_s3

if sys.version_info >= (3, 8):
from moto import mock_aws as moto_mock
else:
# moto v5 doesn't support py37; fall back to v4 with mock_s3
from moto import mock_s3 as moto_mock

has_boto = True
except ImportError:
Expand All @@ -32,7 +38,7 @@ def __init__(self):

@pytest.fixture
def test_bucket_mock():
with mock_s3():
with moto_mock():
res = boto3.client("s3")
res.create_bucket(Bucket="compute-test-1")
yield
Expand Down

0 comments on commit 04b9612

Please sign in to comment.