我正在尝试按照文档执行此操作:
@pytest.fixture()
def aws_credentials():
"""Mocked AWS Credentials for moto."""
os.environ["AWS_ACCESS_KEY_ID"] = "testing"
os.environ["AWS_SECRET_ACCESS_KEY"] = "testing"
os.environ["AWS_SECURITY_TOKEN"] = "testing"
os.environ["AWS_SESSION_TOKEN"] = "testing"
@pytest.fixture()
def sts(aws_credentials):
with mock_sts():
yield boto3.client("sts", region_name="us-east-1")
@pytest.fixture
def sns(aws_credentials):
with mock_sns():
yield boto3.resource("sns", region_name="us-east-1")
def test_publish(sns):
resp = sns.create_topic(Name="sdfsdfsdfsd")
我得到错误:
def test_publish(sns):
> topic_arn = sns.create_topic(Name="sdfsdfsdfsd")
E AttributeError: 'generator' object has no attribute 'create_topic'