我正在使用下面的代码在本地运行测试用例,但它要求提供我不应该提供的aws凭据。它就像mock/moto是如何失败的。由于我是python和itss库的新手,我无法更深入地理解它。
import sys, os
import pprint
myPath = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, myPath + '/../')
from botocore.exceptions import ClientError
pprint.pprint(sys.path)
import pytest
from services.testrun_result_details import *
import json
from moto import *
from mock import MagicMock, patch
import boto3
@mock_dynamodb2
@patch('boto3.resource')
def test_success_response(dynamodb_test_testrun_results):
create_dynamodb_tables()
response = run_result_details_handler(EVENT_JSON, None)
assert response["statusCode"] == 200/usr/local/lib/python3.7/site-packages/botocore/signers.py:90: in handler
return self.sign(operation_name, request)
/usr/local/lib/python3.7/site-packages/botocore/signers.py:162: in sign
auth.add_auth(request)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <botocore.auth.SigV4Auth object at 0x7fab7fc2ee50>
request = <botocore.awsrequest.AWSRequest object at 0x7fab7fc48d90>
def add_auth(self, request):
if self.credentials is None:
> raise NoCredentialsError()
E botocore.exceptions.NoCredentialsError: Unable to locate credentials
/usr/local/lib/python3.7/site-packages/botocore/auth.py:373: NoCredentialsError有没有人能给我一些建议,如何解决这个问题?
发布于 2021-11-15 16:32:00
我发现问题出在我的~/.aws/credentials文件没有default配置文件。
我添加了这个,它解决了这个问题:
[default]
aws_access_key_id = 123
aws_secret_access_key = ABChttps://stackoverflow.com/questions/68738851
复制相似问题