From d475bd27a5dc1770094c940d1f1f26535b93bb84 Mon Sep 17 00:00:00 2001 From: Michael Bauer Date: Fri, 19 Jul 2024 15:02:55 +1000 Subject: [PATCH 1/4] Ran tests for Django 5.0, updated tests to include new area-invalid tag in form --- .gitignore | 3 +++ README.md | 2 +- poetry.lock | 58 +++++++++++++++++++++--------------------- pyproject.toml | 3 ++- tests/test_backends.py | 24 ++++++++++++----- 5 files changed, 52 insertions(+), 38 deletions(-) diff --git a/.gitignore b/.gitignore index 54f234e..8ef0ace 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,6 @@ my_root_certs.crt .flake8 conf/ + +# Python Virtual Environment +venv diff --git a/README.md b/README.md index b579dee..9459572 100644 --- a/README.md +++ b/README.md @@ -27,5 +27,5 @@ Changes made in this fork: - Upgraded to use pyproject.toml - Use github actions over travis-ci - Python 3.12 compatibilty -- Django 4.2 compatibilty +- Django 5.0 compatibilty - Removed crispy-forms integration diff --git a/poetry.lock b/poetry.lock index 1f924f0..1078d9c 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. [[package]] name = "asgiref" @@ -150,17 +150,17 @@ files = [ [[package]] name = "django" -version = "4.2.13" +version = "5.0.7" description = "A high-level Python web framework that encourages rapid development and clean, pragmatic design." optional = false -python-versions = ">=3.8" +python-versions = ">=3.10" files = [ - {file = "Django-4.2.13-py3-none-any.whl", hash = "sha256:a17fcba2aad3fc7d46fdb23215095dbbd64e6174bf4589171e732b18b07e426a"}, - {file = "Django-4.2.13.tar.gz", hash = "sha256:837e3cf1f6c31347a1396a3f6b65688f2b4bb4a11c580dcb628b5afe527b68a5"}, + {file = "Django-5.0.7-py3-none-any.whl", hash = "sha256:f216510ace3de5de01329463a315a629f33480e893a9024fc93d8c32c22913da"}, + {file = "Django-5.0.7.tar.gz", hash = "sha256:bd4505cae0b9bd642313e8fb71810893df5dc2ffcacaa67a33af2d5cd61888f2"}, ] [package.dependencies] -asgiref = ">=3.6.0,<4" +asgiref = ">=3.7.0,<4" sqlparse = ">=0.3.1" tzdata = {version = "*", markers = "sys_platform == \"win32\""} @@ -198,32 +198,32 @@ tokenize-rt = ">=4.1" [[package]] name = "djangorestframework" -version = "3.15.1" +version = "3.15.2" description = "Web APIs for Django, made easy." optional = false -python-versions = ">=3.6" +python-versions = ">=3.8" files = [ - {file = "djangorestframework-3.15.1-py3-none-any.whl", hash = "sha256:3ccc0475bce968608cf30d07fb17d8e52d1d7fc8bfe779c905463200750cbca6"}, - {file = "djangorestframework-3.15.1.tar.gz", hash = "sha256:f88fad74183dfc7144b2756d0d2ac716ea5b4c7c9840995ac3bfd8ec034333c1"}, + {file = "djangorestframework-3.15.2-py3-none-any.whl", hash = "sha256:2b8871b062ba1aefc2de01f773875441a961fefbf79f5eed1e32b2f096944b20"}, + {file = "djangorestframework-3.15.2.tar.gz", hash = "sha256:36fe88cd2d6c6bec23dca9804bab2ba5517a8bb9d8f47ebc68981b56840107ad"}, ] [package.dependencies] -django = ">=3.0" +django = ">=4.2" [[package]] name = "filelock" -version = "3.14.0" +version = "3.15.4" description = "A platform independent file lock." optional = false python-versions = ">=3.8" files = [ - {file = "filelock-3.14.0-py3-none-any.whl", hash = "sha256:43339835842f110ca7ae60f1e1c160714c5a6afd15a2873419ab185334975c0f"}, - {file = "filelock-3.14.0.tar.gz", hash = "sha256:6ea72da3be9b8c82afd3edcf99f2fffbb5076335a5ae4d03248bb5b6c3eae78a"}, + {file = "filelock-3.15.4-py3-none-any.whl", hash = "sha256:6ca1fffae96225dab4c6eaf1c4f4f28cd2568d3ec2a44e15a08520504de468e7"}, + {file = "filelock-3.15.4.tar.gz", hash = "sha256:2207938cbc1844345cb01a5a95524dae30f0ce089eba5b00378295a17e3e90cb"}, ] [package.extras] docs = ["furo (>=2023.9.10)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.25.2)"] -testing = ["covdefaults (>=2.3)", "coverage (>=7.3.2)", "diff-cover (>=8.0.1)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)", "pytest-timeout (>=2.2)"] +testing = ["covdefaults (>=2.3)", "coverage (>=7.3.2)", "diff-cover (>=8.0.1)", "pytest (>=7.4.3)", "pytest-asyncio (>=0.21)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)", "pytest-timeout (>=2.2)", "virtualenv (>=20.26.2)"] typing = ["typing-extensions (>=4.8)"] [[package]] @@ -306,13 +306,13 @@ flake8 = "*" [[package]] name = "identify" -version = "2.5.36" +version = "2.6.0" description = "File identification library for Python" optional = false python-versions = ">=3.8" files = [ - {file = "identify-2.5.36-py2.py3-none-any.whl", hash = "sha256:37d93f380f4de590500d9dba7db359d0d3da95ffe7f9de1753faa159e71e7dfa"}, - {file = "identify-2.5.36.tar.gz", hash = "sha256:e5e00f54165f9047fbebeb4a560f9acfb8af4c88232be60a488e9b68d122745d"}, + {file = "identify-2.6.0-py2.py3-none-any.whl", hash = "sha256:e79ae4406387a9d300332b5fd366d8994f1525e8414984e1a59e058b2eda2dd0"}, + {file = "identify-2.6.0.tar.gz", hash = "sha256:cb171c685bdc31bcc4c1734698736a7d5b6c8bf2e0c15117f4d469c8640ae5cf"}, ] [package.extras] @@ -402,13 +402,13 @@ files = [ [[package]] name = "packaging" -version = "24.0" +version = "24.1" description = "Core utilities for Python packages" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "packaging-24.0-py3-none-any.whl", hash = "sha256:2ddfb553fdf02fb784c234c7ba6ccc288296ceabec964ad2eae3777778130bc5"}, - {file = "packaging-24.0.tar.gz", hash = "sha256:eb82c5e3e56209074766e6885bb04b8c38a0c015d0a30036ebe7ece34c9989e9"}, + {file = "packaging-24.1-py3-none-any.whl", hash = "sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124"}, + {file = "packaging-24.1.tar.gz", hash = "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002"}, ] [[package]] @@ -611,13 +611,13 @@ files = [ [[package]] name = "sqlparse" -version = "0.5.0" +version = "0.5.1" description = "A non-validating SQL parser." optional = false python-versions = ">=3.8" files = [ - {file = "sqlparse-0.5.0-py3-none-any.whl", hash = "sha256:c204494cd97479d0e39f28c93d46c0b2d5959c7b9ab904762ea6c7af211c8663"}, - {file = "sqlparse-0.5.0.tar.gz", hash = "sha256:714d0a4932c059d16189f58ef5411ec2287a4360f17cdd0edd2d09d4c5087c93"}, + {file = "sqlparse-0.5.1-py3-none-any.whl", hash = "sha256:773dcbf9a5ab44a090f3441e2180efe2560220203dc2f8c0b0fa141e18b505e4"}, + {file = "sqlparse-0.5.1.tar.gz", hash = "sha256:bb6b4df465655ef332548e24f08e205afc81b9ab86cb1c45657a7ff173a3a00e"}, ] [package.extras] @@ -662,13 +662,13 @@ files = [ [[package]] name = "virtualenv" -version = "20.26.2" +version = "20.26.3" description = "Virtual Python Environment builder" optional = false python-versions = ">=3.7" files = [ - {file = "virtualenv-20.26.2-py3-none-any.whl", hash = "sha256:a624db5e94f01ad993d476b9ee5346fdf7b9de43ccaee0e0197012dc838a0e9b"}, - {file = "virtualenv-20.26.2.tar.gz", hash = "sha256:82bf0f4eebbb78d36ddaee0283d43fe5736b53880b8a8cdcd37390a07ac3741c"}, + {file = "virtualenv-20.26.3-py3-none-any.whl", hash = "sha256:8cc4a31139e796e9a7de2cd5cf2489de1217193116a8fd42328f1bd65f434589"}, + {file = "virtualenv-20.26.3.tar.gz", hash = "sha256:4c43a2a236279d9ea36a0d76f98d84bd6ca94ac4e0f4a3b9d46d05e10fea542a"}, ] [package.dependencies] @@ -683,4 +683,4 @@ test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess [metadata] lock-version = "2.0" python-versions = "~3.12" -content-hash = "b28efeabdf6b4dafcd5de6fcc25fb80c7b04141d1b2c415b79cd5f2af2773bdb" +content-hash = "cdde46e06d2400e4338ca19337d0736378d8340916b1f664f7973450e2c0c270" diff --git a/pyproject.toml b/pyproject.toml index 0808803..ef77166 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,7 @@ exclude = [ [tool.poetry.dependencies] python = "~3.12" -django = "^4.2" +django = ">4.2" django-filter = "^24.2" djangorestframework = "^3.15" @@ -57,6 +57,7 @@ isort = "5.13.2" bandit = "1.7.8" # test django-upgrade = "1.18.0" +packaging = "24.1" [build-system] requires = ["poetry-core"] diff --git a/tests/test_backends.py b/tests/test_backends.py index 8379210..b865db0 100644 --- a/tests/test_backends.py +++ b/tests/test_backends.py @@ -1,6 +1,8 @@ from urllib.parse import quote, urlencode +from packaging.version import Version import django_filters +import django from django.test import modify_settings from rest_framework import status from rest_framework.test import APIRequestFactory, APITestCase @@ -227,10 +229,7 @@ class NoteFilter(FilterSet): class RelatedViewSet(views.NoteViewSet): filterset_class = NoteFilter - context = {"author": "invalid", "author__last_login": "invalid"} - self.assertHTMLEqual( - self.render(RelatedViewSet, context), - """ + assert_html_options = list(map(lambda aria: f"""

Field filters

-

@@ -255,7 +254,7 @@ class RelatedViewSet(views.NoteViewSet):

- @@ -264,7 +263,18 @@ class RelatedViewSet(views.NoteViewSet):

- """, + """ , ['', 'aria-invalid="true"'])) + + # Django >5.0 adds aria-invalid="true", but want old Django version to pass as well + if Version(django.__version__) < Version("5.0"): + assert_html = assert_html_options[0] + else: + assert_html = assert_html_options[1] + + context = {"author": "invalid", "author__last_login": "invalid"} + self.assertHTMLEqual( + self.render(RelatedViewSet, context), + assert_html, ) def test_rendering_doesnt_affect_filterset_classes(self): From fc2e41cec6acc7bc3f8da327887cc219b8d3b0b7 Mon Sep 17 00:00:00 2001 From: Michael Bauer Date: Wed, 24 Jul 2024 11:29:26 +1000 Subject: [PATCH 2/4] More specific versions specified as supported --- README.md | 2 +- poetry.lock | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9459572..1627037 100644 --- a/README.md +++ b/README.md @@ -27,5 +27,5 @@ Changes made in this fork: - Upgraded to use pyproject.toml - Use github actions over travis-ci - Python 3.12 compatibilty -- Django 5.0 compatibilty +- Django >4.2,<5.1 compatibility - Removed crispy-forms integration diff --git a/poetry.lock b/poetry.lock index 1078d9c..4cf6db5 100644 --- a/poetry.lock +++ b/poetry.lock @@ -683,4 +683,4 @@ test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess [metadata] lock-version = "2.0" python-versions = "~3.12" -content-hash = "cdde46e06d2400e4338ca19337d0736378d8340916b1f664f7973450e2c0c270" +content-hash = "d568ac791c0f37d745f0e85edf5388a960d60ea31c764a7e88c94814b36d2691" diff --git a/pyproject.toml b/pyproject.toml index ef77166..d7fb18b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,7 @@ exclude = [ [tool.poetry.dependencies] python = "~3.12" -django = ">4.2" +django = ">4.2,<5.1" django-filter = "^24.2" djangorestframework = "^3.15" From ff837a9bce78c17ae707a10676135267941e1ed9 Mon Sep 17 00:00:00 2001 From: Michael Bauer Date: Wed, 24 Jul 2024 13:21:35 +1000 Subject: [PATCH 3/4] Ran black formatter --- tests/test_backends.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/test_backends.py b/tests/test_backends.py index b865db0..8157ad8 100644 --- a/tests/test_backends.py +++ b/tests/test_backends.py @@ -229,7 +229,9 @@ class NoteFilter(FilterSet): class RelatedViewSet(views.NoteViewSet): filterset_class = NoteFilter - assert_html_options = list(map(lambda aria: f""" + assert_html_options = list( + map( + lambda aria: f"""

Field filters

    @@ -263,7 +265,10 @@ class RelatedViewSet(views.NoteViewSet): - """ , ['', 'aria-invalid="true"'])) + """, + ["", 'aria-invalid="true"'], + ) + ) # Django >5.0 adds aria-invalid="true", but want old Django version to pass as well if Version(django.__version__) < Version("5.0"): From a662dab791e4d24a2ccbce0c581d3b2f05fd84ce Mon Sep 17 00:00:00 2001 From: Sunny Rangnani Date: Fri, 26 Jul 2024 09:51:09 -0400 Subject: [PATCH 4/4] linting fixes --- README.md | 2 +- poetry.lock | 4 ++-- pyproject.toml | 2 +- tests/test_backends.py | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1627037..aabd87e 100644 --- a/README.md +++ b/README.md @@ -27,5 +27,5 @@ Changes made in this fork: - Upgraded to use pyproject.toml - Use github actions over travis-ci - Python 3.12 compatibilty -- Django >4.2,<5.1 compatibility +- Django >=4.2,<5.1 compatibility - Removed crispy-forms integration diff --git a/poetry.lock b/poetry.lock index 4cf6db5..c1bf919 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand. [[package]] name = "asgiref" @@ -683,4 +683,4 @@ test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess [metadata] lock-version = "2.0" python-versions = "~3.12" -content-hash = "d568ac791c0f37d745f0e85edf5388a960d60ea31c764a7e88c94814b36d2691" +content-hash = "2dc7cff4053524224ada035cb6d0a656c313d05f3a3a0397abb09cd8a1534df7" diff --git a/pyproject.toml b/pyproject.toml index dfe3851..cfd6188 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,7 @@ exclude = [ [tool.poetry.dependencies] python = "~3.12" -django = ">4.2,<5.1" +django = ">=4.2,<5.1" django-filter = "^24.2" djangorestframework = "^3.15" diff --git a/tests/test_backends.py b/tests/test_backends.py index 8157ad8..48c29ec 100644 --- a/tests/test_backends.py +++ b/tests/test_backends.py @@ -1,9 +1,9 @@ from urllib.parse import quote, urlencode -from packaging.version import Version -import django_filters import django +import django_filters from django.test import modify_settings +from packaging.version import Version from rest_framework import status from rest_framework.test import APIRequestFactory, APITestCase