-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
can not stop mocking after moto==1.3.14 #2575
Comments
What happens when you use the Context Manager: https://github.com/spulec/moto#context-manager ? |
You mean using Context Manager like following? import boto3
import moto
if __name__ == '__main__':
print(moto.__version__)
with moto.mock_dynamodb2():
boto3.client('dynamodb')
bucket = boto3.resource('s3').Bucket('test-bucket')
print(list(bucket.objects.filter(Prefix='dummy'))) It does not work as well. $ AWS_ACCESS_KEY_ID=xxx AWS_SECRET_ACCESS_KEY=xxx AWS_DEFAULT_REGION=xxx python main.py
1.3.14
Traceback (most recent call last):
File "main.py", line 10, in <module>
print(list(bucket.objects.filter(Prefix='dummy')))
File "/home/nakagawa/.pyenv/versions/3.6.8/lib/python3.6/site-packages/boto3/resources/collection.py", line 83, in __iter__
for page in self.pages():
File "/home/nakagawa/.pyenv/versions/3.6.8/lib/python3.6/site-packages/boto3/resources/collection.py", line 166, in pages
for page in pages:
File "/home/nakagawa/.pyenv/versions/3.6.8/lib/python3.6/site-packages/botocore/paginate.py", line 255, in __iter__
response = self._make_request(current_kwargs)
File "/home/nakagawa/.pyenv/versions/3.6.8/lib/python3.6/site-packages/botocore/paginate.py", line 332, in _make_request
return self._method(**current_kwargs)
File "/home/nakagawa/.pyenv/versions/3.6.8/lib/python3.6/site-packages/botocore/client.py", line 357, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/home/nakagawa/.pyenv/versions/3.6.8/lib/python3.6/site-packages/botocore/client.py", line 661, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (InvalidAccessKeyId) when calling the ListObjects operation: The AWS Access Key Id you provided does not exist in our records. |
Well that's no good :( |
Hmm... while doing some debugging, I found that in botocore's |
For some reason, the
|
I have a hunch that what we need to do is mock the boto3 It appears that:
... is being cached and used after the mock has ended. |
Preliminary PR for fixing this is in #2578. Will need to do more testing. Feel free to pip install from my repo branch and test that it works for you. |
Thank you! It works fine after |
Glad to hear that! I will merge it in once I get the tests to pass. |
- Fixes getmoto#2575 - Also upgraded Travis CI to make use of Bionic instead of Xenial - This may also address concerns raised in getmoto#1793
- Fixes getmoto#2575 - Also upgraded Travis CI to make use of Bionic instead of Xenial - This may also address concerns raised in getmoto#1793
versions
$ python --version Python 3.6.8 $ pip freeze | grep boto boto==2.49.0 boto3==1.10.19 botocore==1.13.19
Reporting Bugs
I mock only DynamoDB and run S3 client on real environment. But it has not worked since I update moto to
1.3.14
.Here is a minimum sample code.
Although this code works on
moto==1.3.13
,does not work on
moto==1.3.14
.The text was updated successfully, but these errors were encountered: