From 916d33b5df1399b8e5371798f19987f1383d777f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20M=C3=A1tl?= Date: Tue, 20 Dec 2022 19:57:59 +0100 Subject: [PATCH] Support newer pythons --- .editorconfig | 2 +- .github/workflows/django.yml | 17 +++++++++---- LICENSE | 24 +++++++++++++------ README.md | 2 +- chamber/utils/datastructures.py | 4 ++-- .../test_chamber/tests/formatters/__init__.py | 4 ++-- .../apps/test_chamber/tests/models/fields.py | 4 ++-- .../tests/models/humanized_helpers.py | 4 ++-- .../apps/test_chamber/tests/storages/boto3.py | 4 ++-- .../apps/test_chamber/tests/utils/__init__.py | 6 ++--- example/requirements.txt | 2 +- setup.py | 9 +++++-- 12 files changed, 53 insertions(+), 29 deletions(-) diff --git a/.editorconfig b/.editorconfig index 5cbb2cd..ac2ce03 100644 --- a/.editorconfig +++ b/.editorconfig @@ -17,7 +17,7 @@ indent_size = 4 indent_style = space indent_size = 4 line_length=120 -known_third_party=factory,ipware,responses,requests,nose,south,coverage,six,suds,geopy,user_agents,celery,dateutil,jsonfield,easymode,PIL,pillow,mock,xlrd,attrdict,jinja2,phonenumber_field,magic +known_third_party=factory,ipware,responses,requests,nose,south,coverage,six,suds,geopy,user_agents,celery,dateutil,jsonfield,easymode,PIL,pillow,mock,xlrd,jinja2,phonenumber_field,magic multi_line_output=0 lines_after_imports=2 known_django=django diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index 73794c6..7fa968c 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -13,16 +13,25 @@ jobs: max-parallel: 4 matrix: include: - - python-version: 3.7 + - python-version: "3.7" django-version: Django==3.1 - - python-version: 3.8 + - python-version: "3.8" django-version: Django==3.1 - - python-version: 3.7 + - python-version: "3.7" django-version: Django==3.2 - - python-version: 3.8 + - python-version: "3.8" + django-version: Django==3.2 + + - python-version: "3.9" + django-version: Django==3.2 + + - python-version: "3.10" + django-version: Django==3.2 + + - python-version: "3.11" django-version: Django==3.2 steps: diff --git a/LICENSE b/LICENSE index 923409f..f52d354 100644 --- a/LICENSE +++ b/LICENSE @@ -1,11 +1,21 @@ -Copyright 2017 Luboš Mátl, Lukáš Rychtecký, Oskar Hollmann +MIT License -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: +Copyright (c) 2019 django-GDPR -1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. -3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index dd24461..cf60b36 100644 --- a/README.md +++ b/README.md @@ -38,4 +38,4 @@ You are welcomed to contribute at https://github.com/druids/django-chamber. Ther ## License -This library is licenced under the 3-clause BSD licence. See the LICENCE file for details. +This library is licenced under MIT licence. See the LICENCE file for details. diff --git a/chamber/utils/datastructures.py b/chamber/utils/datastructures.py index df5324e..b3d82ec 100644 --- a/chamber/utils/datastructures.py +++ b/chamber/utils/datastructures.py @@ -1,6 +1,6 @@ import re -from collections import MutableSet, OrderedDict +from collections.abc import MutableSet from itertools import chain @@ -16,7 +16,7 @@ def __init__(self, *items): if not ENUM_KEY_PATTERN.match(k): raise ValueError('Enum key "{}" has invalid format'.format(k)) - self._container = OrderedDict(items) + self._container = dict(items) self._reverse_container = {item[1]: item[0] for item in items} def _has_attr(self, name): diff --git a/example/dj/apps/test_chamber/tests/formatters/__init__.py b/example/dj/apps/test_chamber/tests/formatters/__init__.py index e624a0a..4f5a904 100644 --- a/example/dj/apps/test_chamber/tests/formatters/__init__.py +++ b/example/dj/apps/test_chamber/tests/formatters/__init__.py @@ -2,7 +2,7 @@ from chamber.formatters import natural_number_with_currency -from germanium.decorators import data_provider # pylint: disable=E0401 +from germanium.decorators import data_consumer # pylint: disable=E0401 from germanium.tools import assert_equal # pylint: disable=E0401 @@ -15,6 +15,6 @@ class FormattersTestCase(TestCase): (1000000.00, 'CZK', False, True, '1\xa0000\xa0000\xa0CZK'), ) - @data_provider(numbers_with_currencies) + @data_consumer(numbers_with_currencies) def test_should_return_natural_number_with_currency(self, number, currency, show_decimal_place, use_nbsp, expected): assert_equal(expected, natural_number_with_currency(number, currency, show_decimal_place, use_nbsp)) diff --git a/example/dj/apps/test_chamber/tests/models/fields.py b/example/dj/apps/test_chamber/tests/models/fields.py index c9c8e59..1e2a551 100644 --- a/example/dj/apps/test_chamber/tests/models/fields.py +++ b/example/dj/apps/test_chamber/tests/models/fields.py @@ -11,7 +11,7 @@ from chamber.models.fields import generate_random_upload_path from chamber.shortcuts import change_and_save -from germanium.decorators import data_provider +from germanium.decorators import data_consumer from germanium.tools import assert_equal, assert_is_none, assert_false, assert_is_not_none, assert_raises, assert_true from test_chamber.models import CSVRecord, TestFieldsModel # pylint: disable=E0401 @@ -146,7 +146,7 @@ def test_should_check_total_price_form_field(self): ('total_price', ugettext_lazy('CZK'), {'max_digits', 'decimal_places', 'validators'}), ) - @data_provider(model_fields) + @data_consumer(model_fields) def test_should_assert_form_field(self, field_name, currency, kwargs_to_remove): field = TestFieldsModel._meta.get_field(field_name) # pylint: disable=W0212 assert_equal(currency, field.currency) diff --git a/example/dj/apps/test_chamber/tests/models/humanized_helpers.py b/example/dj/apps/test_chamber/tests/models/humanized_helpers.py index 95b1b6a..fb9640f 100644 --- a/example/dj/apps/test_chamber/tests/models/humanized_helpers.py +++ b/example/dj/apps/test_chamber/tests/models/humanized_helpers.py @@ -2,7 +2,7 @@ from chamber.models.humanized_helpers import price_humanized -from germanium.decorators import data_provider # pylint: disable=E0401 +from germanium.decorators import data_consumer # pylint: disable=E0401 from germanium.tools import assert_equal # pylint: disable=E0401 @@ -15,6 +15,6 @@ class HumanizedHelpersTestCase(TestCase): (None, None, '(None)'), ) - @data_provider(numbers_with_currencies) + @data_consumer(numbers_with_currencies) def test_should_return_price_humanized(self, number, currency, expected): assert_equal(expected, price_humanized(number, None, currency)) diff --git a/example/dj/apps/test_chamber/tests/storages/boto3.py b/example/dj/apps/test_chamber/tests/storages/boto3.py index 8f96e41..a2d486b 100644 --- a/example/dj/apps/test_chamber/tests/storages/boto3.py +++ b/example/dj/apps/test_chamber/tests/storages/boto3.py @@ -3,7 +3,7 @@ from chamber.storages.boto3 import force_bytes_content -from germanium.decorators import data_provider +from germanium.decorators import data_consumer class S3StorageTestCase(TestCase): @@ -13,7 +13,7 @@ class S3StorageTestCase(TestCase): (b'Hello, this is bytes content.', b'Hello, this is bytes content.', False), ) - @data_provider(TEST_DATA) + @data_consumer(TEST_DATA) def test_s3storage_casts_content_to_bytes_if_needed(self, content, content_result, should_cast): file = ContentFile(content) result, casted = force_bytes_content(file) diff --git a/example/dj/apps/test_chamber/tests/utils/__init__.py b/example/dj/apps/test_chamber/tests/utils/__init__.py index 3489676..08cb053 100644 --- a/example/dj/apps/test_chamber/tests/utils/__init__.py +++ b/example/dj/apps/test_chamber/tests/utils/__init__.py @@ -9,7 +9,7 @@ get_class_method, keep_spacing, remove_accent, call_function_with_unknown_input, InvalidFunctionArguments ) -from germanium.decorators import data_provider # pylint: disable=E0401 +from germanium.decorators import data_consumer # pylint: disable=E0401 from germanium.tools import assert_equal, assert_true # pylint: disable=E0401 from .datastructures import * # NOQA @@ -60,7 +60,7 @@ def test_should_remove_accent_from_string_when_unicode_error(self): [None, TestClass(), 'invalid'], ] - @data_provider(classes_and_method_names) + @data_consumer(classes_and_method_names) def test_get_class_method_should_return_right_class_method_or_none(self, expected_method, cls_or_inst, method_name): assert_equal(expected_method, get_class_method(cls_or_inst, method_name)) @@ -72,7 +72,7 @@ def test_get_class_method_should_return_right_class_method_or_none(self, expecte ['Hello escaped
world', mark_safe('Hello escaped \r\nworld'), True] ] - @data_provider(values_for_keep_spacing) + @data_consumer(values_for_keep_spacing) def test_should_keep_spacing(self, expected, value, autoescape): escaped_value = keep_spacing(value, autoescape) assert_equal(expected, escaped_value) diff --git a/example/requirements.txt b/example/requirements.txt index 87afc69..608ac41 100644 --- a/example/requirements.txt +++ b/example/requirements.txt @@ -3,7 +3,7 @@ flake8 freezegun==1.1.0 coveralls diff-match-patch==20110725.1 -django-germanium==2.1.0 +https://github.com/druids/germanium/tarball/SupportPython3.9-3.11#egg=django-germanium six==1.10.0 Pillow==9.3.0 boto3==1.16.47 diff --git a/setup.py b/setup.py index a5ed489..8f9f880 100644 --- a/setup.py +++ b/setup.py @@ -4,6 +4,7 @@ setup( + python_requires=">=3.6", name='django-chamber', version=get_version(), description='Utilities library meant as a complement to django-is-core.', @@ -19,8 +20,12 @@ 'License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)', 'Operating System :: OS Independent', 'Programming Language :: Python', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', 'Framework :: Django', ], install_requires=[