From 04c3ad536d7d9c950574edfd37a4ed04ef439532 Mon Sep 17 00:00:00 2001 From: edef Date: Wed, 3 Apr 2024 11:36:21 +0000 Subject: [PATCH] support moto 5.x Fix #54 --- pyproject.toml | 2 +- tests/fixtures/aws.py | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2f4d8c4..276c6d2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,7 +28,7 @@ pyarrow = "14.0.2" # various test outputs are sensitive to this pylint = "^3.0.3" pytest = "^7.4.3" pytest-mock = "^3.12.0" -moto = "^4.2.12" +moto = ">=4.2.12 <6" wheel = "^0.42.0" twine = "^4.0.2" diff --git a/tests/fixtures/aws.py b/tests/fixtures/aws.py index 7eea4bd..9fb3345 100644 --- a/tests/fixtures/aws.py +++ b/tests/fixtures/aws.py @@ -1,15 +1,17 @@ import boto3 -from moto import mock_s3 import pytest +try: + # Moto 4.x + from moto import mock_s3 +except ImportError: + # Moto 5.x + from moto import mock_aws as mock_s3 @pytest.fixture def aws_session(): - mock_s3_server = mock_s3() - mock_s3_server.start() - yield boto3.Session() - mock_s3_server.stop() - + with mock_s3(): + yield boto3.Session() @pytest.fixture def aws_s3_bucket(aws_session):