Skip to content

Commit 8c4f437

Browse files
committed
fix moto>=5 rename of test mock utility for AWS S3
1 parent 3a6cc58 commit 8c4f437

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

CHANGES.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Changes:
1616

1717
Fixes:
1818
------
19-
- No change.
19+
- Fix ``moto>=5`` used in tests to mock AWS S3 operations that replaced ``mock_s3`` context manager by ``mock_aws``.
2020

2121
.. _changes_5.0.0:
2222

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ check-all: install-dev $(CHECKS_ALL) ## check all code linters
492492

493493
.PHONY: check-pep8-only
494494
check-pep8-only: mkdir-reports ## check for PEP8 code style issues
495-
@echo "Running pep8 code style checks..."
495+
@echo "Running PEP8 code style checks..."
496496
@-rm -fr "$(REPORTS_DIR)/check-pep8.txt"
497497
@bash -c '$(CONDA_CMD) \
498498
flake8 --config="$(APP_ROOT)/setup.cfg" --output-file="$(REPORTS_DIR)/check-pep8.txt" --tee'

setup.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ exclude =
103103
env,
104104
parts,
105105
examples,
106+
node_modules,
106107

107108
[doc8]
108109
max-line-length = 120

tests/utils.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
from weaver import __name__ as __package__
4040
from weaver.app import main as weaver_app
41+
from weaver.compat import Version
4142
from weaver.config import WEAVER_DEFAULT_INI_CONFIG, WeaverConfiguration, get_weaver_config_file
4243
from weaver.database import get_db
4344
from weaver.datatype import Service
@@ -1285,7 +1286,11 @@ def mocked_aws_s3(test_func):
12851286
@functools.wraps(test_func)
12861287
def wrapped(*args, **kwargs):
12871288
# type: (*Any, **Any) -> Any
1288-
with moto.mock_s3():
1289+
if Version(moto.__version__).major >= 5:
1290+
mock_aws_s3 = moto.mock_aws # pylint: disable=E1101,no-member
1291+
else:
1292+
mock_aws_s3 = moto.mock_s3 # pylint: disable=E1101,no-member
1293+
with mock_aws_s3():
12891294
return test_func(*args, **kwargs)
12901295
return wrapped
12911296

0 commit comments

Comments
 (0)