moto/tests/test_core/test_mypy.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

43 lines
930 B
Python
Raw Normal View History

2023-11-21 23:51:03 +00:00
import boto3
from moto import mock_aws
from moto.core.decorator import MockAWS
2023-11-21 23:51:03 +00:00
2024-01-07 12:03:33 +00:00
@mock_aws
2023-11-21 23:51:03 +00:00
def test_without_parentheses() -> int:
assert boto3.client("s3").list_buckets()["Buckets"] == []
return 123
2024-01-07 12:03:33 +00:00
@mock_aws()
2023-11-21 23:51:03 +00:00
def test_with_parentheses() -> int:
assert boto3.client("s3").list_buckets()["Buckets"] == []
return 456
2024-01-07 12:03:33 +00:00
@mock_aws
2023-11-21 23:51:03 +00:00
def test_no_return() -> None:
assert boto3.client("s3").list_buckets()["Buckets"] == []
def test_with_context_manager() -> None:
2024-01-07 12:03:33 +00:00
with mock_aws():
2023-11-21 23:51:03 +00:00
assert boto3.client("s3").list_buckets()["Buckets"] == []
def test_manual() -> None:
# this has the explicit type not because it's necessary but so that mypy will
# complain if it's wrong
2024-01-07 12:03:33 +00:00
m: MockAWS = mock_aws()
2023-11-21 23:51:03 +00:00
m.start()
assert boto3.client("s3").list_buckets()["Buckets"] == []
m.stop()
x: int = test_with_parentheses()
assert x == 456
y: int = test_without_parentheses()
assert y == 123