From 065c9b71ec67141040c424ab3c26a17410581a43 Mon Sep 17 00:00:00 2001 From: Henri Hulski Date: Mon, 19 Sep 2022 19:03:59 +0200 Subject: [PATCH] chore: add support for Django 4.1 --- .github/workflows/main.yml | 7 +++++++ setup.cfg | 1 + tests/test_shop.py | 22 +++++++++++++++------- tox.ini | 3 ++- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d91be2b4..7187d80f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,6 +37,13 @@ jobs: python-version: "3.9" - tox-env: "py310-dj40" python-version: "3.10" + # Django 4.1 + - tox-env: "py38-dj41" + python-version: "3.8" + - tox-env: "py39-dj41" + python-version: "3.9" + - tox-env: "py310-dj41" + python-version: "3.10" steps: - uses: actions/checkout@v3 diff --git a/setup.cfg b/setup.cfg index bb174d9d..d1477bbe 100644 --- a/setup.cfg +++ b/setup.cfg @@ -26,6 +26,7 @@ classifiers = Framework :: Django :: 2.2 Framework :: Django :: 3.2 Framework :: Django :: 4.0 + Framework :: Django :: 4.1 Topic :: Internet :: WWW/HTTP Topic :: Internet :: WWW/HTTP :: Dynamic Content Topic :: Internet :: WWW/HTTP :: WSGI diff --git a/tests/test_shop.py b/tests/test_shop.py index 60eee576..28c1e3b0 100644 --- a/tests/test_shop.py +++ b/tests/test_shop.py @@ -4,6 +4,7 @@ from operator import mul from unittest import skipUnless +import django from django.test import TestCase from django.test.client import RequestFactory from django.urls import reverse @@ -311,12 +312,19 @@ def test_discount_codes(self): self._empty_cart(cart) self._add_to_cart(invalid_variation, 1) r = self.client.post(reverse("shop_cart"), post_data) - self.assertFormError( - r, - "discount_form", - "discount_code", - _("The discount code entered is invalid."), - ) + if django.VERSION >= (4, 1): + self.assertFormError( + r.context["discount_form"], + "discount_code", + _("The discount code entered is invalid."), + ) + else: + self.assertFormError( + r, + "discount_form", + "discount_code", + _("The discount code entered is invalid."), + ) def test_order(self): """ @@ -408,7 +416,7 @@ def test_sale_save(self): """ Regression test for GitHub issue #24. Incorrect exception handle meant that in some cases (usually percentage discount) sale_prices were not - being applied to all products and their variations. + being applied to all products and their varitations. Note: This issues was only relevant using MySQL and with exceptions turned on (which is the default when DEBUG=True). diff --git a/tox.ini b/tox.ini index faddbc72..a4926807 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] envlist = - py{37,38,39,310}-dj{22,32,40} + py{37,38,39,310}-dj{22,32,40,41} package lint @@ -12,6 +12,7 @@ deps = dj22: Django>=2.2, <3 dj32: Django>=3.2, <3.3 dj40: Django>=4.0, <4.1 + dj41: Django>=4.1, <4.2 commands = pytest --basetemp="{envtmpdir}" --junitxml="junit/TEST-{envname}.xml" {posargs}