Skip to content

Commit

Permalink
Migrate 4.x branch's testing and type-testing
Browse files Browse the repository at this point in the history
  • Loading branch information
ikonst committed Dec 7, 2022
1 parent fd68ccf commit 138a1ab
Show file tree
Hide file tree
Showing 11 changed files with 222 additions and 270 deletions.
5 changes: 5 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ warn_unused_configs = True
warn_redundant_casts = True
warn_incomplete_stub = True
follow_imports = normal
show_error_codes = True

# Ignore errors in the docs/conf.py file
[mypy-conf]
ignore_errors = True

# TODO: burn these down
[mypy-tests.*]
Expand Down
2 changes: 1 addition & 1 deletion pynamodb/connection/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def _make_api_call(self, operation_name, operation_kwargs):
code = data.get('__type', '')
if '#' in code:
code = code.rsplit('#', 1)[1]
botocore_expected_format = {'Error': {'Message': data.get('message', ''), 'Code': code}}
botocore_expected_format = {'Error': {'Message': data.get('message', '') or data.get('Message', ''), 'Code': code}}
verbose_properties = {
'request_id': headers.get('x-amzn-RequestId')
}
Expand Down
6 changes: 6 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[pytest]
markers =
ddblocal: requires an mock dynamodb server running on localhost:8000
env =
AWS_ACCESS_KEY_ID=1
AWS_SECRET_ACCESS_KEY=2
15 changes: 7 additions & 8 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
mock
pytest
pytest>=6
pytest-env
pytest-mock

# Due to https://github.com/boto/botocore/issues/1872. Remove after botocore fixes.
python-dateutil==2.8.0

# only used in .travis.yml
# only used in CI
coveralls
mypy==0.761;python_version>="3.7"
mypy==0.950;python_version>="3.7"
pytest-cov
sphinx
sphinx-rtd-theme

# used for type-checking
botocore-stubs
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,16 @@ def find_stubs(package):
setup(
name='pynamodb',
version=__import__('pynamodb').__version__,
packages=find_packages(exclude=('tests', 'tests.integration',)),
packages=find_packages(exclude=('examples', 'tests', 'typing_tests', 'tests.integration',)),
url='http://jlafon.io/pynamodb.html',
project_urls={
'Source': 'https://github.com/pynamodb/PynamoDB',
},
author='Jharrod LaFon',
author_email='[email protected]',
description='A Pythonic Interface to DynamoDB',
long_description=open('README.rst').read(),
long_description_content_type='text/x-rst',
zip_safe=False,
license='MIT',
keywords='python dynamodb amazon',
Expand Down
48 changes: 0 additions & 48 deletions tests/mypy_helpers.py

This file was deleted.

210 changes: 0 additions & 210 deletions tests/test_mypy.py

This file was deleted.

4 changes: 2 additions & 2 deletions tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ def test_override_old_attributes(settings_str, tmpdir):
with patch.dict('os.environ', {'PYNAMODB_CONFIG': str(custom_settings)}):
with pytest.warns(UserWarning) as warns:
reload_module(pynamodb.settings)
assert len(warns) == 1
assert 'options are no longer supported' in str(warns[0].message)

assert any(('options are no longer supported' in str(warn.message)) for warn in warns)
Empty file added typing_tests/__init__.py
Empty file.
Loading

0 comments on commit 138a1ab

Please sign in to comment.