When I use mock_dynamodb2 with python 3.8.2 I get deprecation warnings.
$ pipenv run pip freeze | grep -E 'moto|boto'
boto==2.49.0
boto3==1.13.5
botocore==1.16.5
moto==1.3.14
$ pipenv run python -V
Python 3.8.2
Moto was installed using Pipenv
Given the following pytest file...
import os
import pytest
import boto3
from moto import mock_dynamodb2
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 ddb(scope='function'):
with mock_dynamodb2():
return boto3.client('dynamodb',
region_name='eu-west-1',
aws_access_key_id='testing',
aws_secret_access_key='testing',
aws_session_token='testing')
@mock_dynamodb2
def test_listing_tables(ddb):
# table_name = 'temp-{}'.format(str(uuid4()))
ddb.create_table(
AttributeDefinitions=[
{
'AttributeName': 'Artist',
'AttributeType': 'S',
},
{
'AttributeName': 'SongTitle',
'AttributeType': 'S',
}
],
KeySchema=[
{
'AttributeName': 'Artist',
'KeyType': 'HASH',
},
{
'AttributeName': 'SongTitle',
'KeyType': 'RANGE',
}
],
ProvisionedThroughput={
'ReadCapacityUnits': 5,
'WriteCapacityUnits': 5,
},
TableName='Music',
)
assert ddb.list_tables()['TableNames'] == ['Music']
Deprecation warnings when I run pytest
$ pipenv run pytest
======================================================================================= test session starts =======================================================================================
platform darwin -- Python 3.8.2, pytest-5.4.1, py-1.8.1, pluggy-0.13.1
rootdir: /Users/adrian/code/mowat27/learn/aws/ddbmock, inifile: pytest.ini
collected 1 item
test/test_put_and_scan.py . [100%]
======================================================================================== warnings summary =========================================================================================
/Users/adrian/.local/share/virtualenvs/ddbmock-o4qurhhV/lib/python3.8/site-packages/boto/plugin.py:40
/Users/adrian/.local/share/virtualenvs/ddbmock-o4qurhhV/lib/python3.8/site-packages/boto/plugin.py:40: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
/Users/adrian/.local/share/virtualenvs/ddbmock-o4qurhhV/lib/python3.8/site-packages/moto/cloudformation/parsing.py:407
/Users/adrian/.local/share/virtualenvs/ddbmock-o4qurhhV/lib/python3.8/site-packages/moto/cloudformation/parsing.py:407: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working
class ResourceMap(collections.Mapping):
-- Docs: https://docs.pytest.org/en/latest/warnings.html
================================================================================== 1 passed, 2 warnings in 2.86s ==================================================================================
No warnings
This is annoying but not critical at the moment. I'd like to keep my project up to date with future python releases though.
A search for DeprecationWarning in open issues yielded no results. Sorry if I missed something.
If anyone else is having this problem, note that you can work around this by changing the imports in your test suite to supress the warnings
import warnings
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
import boto3
from moto import mock_dynamodb2
or by using pytest.ini
[pytest]
filterwarnings =
ignore::DeprecationWarning:moto.*:
ignore::DeprecationWarning:boto.*:
Thanks for raising this, and for providing a workaround, @mowat27. Marking this as an enhancement.
Hi @bblommers, it looks like the issue was already fixed on the master #2624
Maybe it is time for a new release again?
This should now be fixed as of moto >= 1.3.16.
I am using moto v1.3.16, installed with pipenv, and this warning still appears. In my case I'm using mock_s3.
/usr/local/lib/python3.8/site-packages/boto/plugin.py:40: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
-- Docs: https://docs.pytest.org/en/stable/warnings.html
Most helpful comment
I am using moto v1.3.16, installed with pipenv, and this warning still appears. In my case I'm using
mock_s3.