From 5029595c6b3f305d99af461a43ee1268f2ab527d Mon Sep 17 00:00:00 2001 From: David Smith Date: Sun, 22 Oct 2023 16:03:27 +0100 Subject: [PATCH] Added support for Django 5.0 and Python 3.11/3.12. --- .github/workflows/CI.yml | 4 +- .github/workflows/publish.yml | 6 +- CHANGELOG.md | 2 + .../templates/tailwind/layout/help_text.html | 4 +- pyproject.toml | 3 + tests/results/filter/crispy_filter.html | 4 +- tests/results/filter/crispy_filter_lt50.html | 77 ++++++++ tests/results/helper/charfield_failing.html | 2 +- .../helper/charfield_failing_lt50.html | 7 + tests/results/helper/col_row.html | 3 +- tests/results/helper/col_row_lt50.html | 40 ++++ tests/results/helper/div.html | 3 +- tests/results/helper/div_lt50.html | 14 ++ tests/results/helper/fieldset.html | 3 +- tests/results/helper/fieldset_lt50.html | 21 ++ tests/results/helper/formset.html | 6 +- tests/results/helper/formset_errors.html | 1 + tests/results/helper/formset_errors_lt50.html | 46 +++++ tests/results/helper/formset_form_tag.html | 6 +- .../results/helper/formset_form_tag_lt50.html | 28 +++ tests/results/helper/formset_lt50.html | 26 +++ tests/results/helper/non_form_errors.html | 2 + .../results/helper/non_form_errors_lt50.html | 34 ++++ tests/results/prepended/appended_errors.html | 9 +- .../prepended/appended_errors_lt50.html | 9 + .../prepended/prepended_appended_errors.html | 9 +- .../prepended_appended_errors_lt50.html | 10 + tests/results/prepended/prepended_errors.html | 9 +- .../prepended/prepended_errors_lt50.html | 9 + tests/results/prepended/prepended_help.html | 3 +- .../prepended/prepended_help_lt50.html | 16 ++ .../table_inline_formset.html | 6 +- .../table_inline_formset_failing.html | 2 +- .../table_inline_formset_failing_lt50.html | 36 ++++ .../table_inline_formset_lt50.html | 179 ++++++++++++++++++ tests/test_filter.py | 7 +- tests/test_helper.py | 49 ++++- tests/test_prepended_appended.py | 25 ++- tests/test_table_inline_formset.py | 13 +- tox.ini | 1 + 40 files changed, 697 insertions(+), 37 deletions(-) create mode 100644 tests/results/filter/crispy_filter_lt50.html create mode 100644 tests/results/helper/charfield_failing_lt50.html create mode 100644 tests/results/helper/col_row_lt50.html create mode 100644 tests/results/helper/div_lt50.html create mode 100644 tests/results/helper/fieldset_lt50.html create mode 100644 tests/results/helper/formset_errors_lt50.html create mode 100644 tests/results/helper/formset_form_tag_lt50.html create mode 100644 tests/results/helper/formset_lt50.html create mode 100644 tests/results/helper/non_form_errors_lt50.html create mode 100644 tests/results/prepended/appended_errors_lt50.html create mode 100644 tests/results/prepended/prepended_appended_errors_lt50.html create mode 100644 tests/results/prepended/prepended_errors_lt50.html create mode 100644 tests/results/prepended/prepended_help_lt50.html create mode 100644 tests/results/table_inline_formset/table_inline_formset_failing_lt50.html create mode 100644 tests/results/table_inline_formset/table_inline_formset_lt50.html diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index dcacdd9..67584ca 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -17,6 +17,8 @@ jobs: - '3.8' - '3.9' - '3.10' + - '3.11' + - '3.12' steps: - uses: actions/checkout@v4 @@ -38,7 +40,7 @@ jobs: ENV_PREFIX=$(tr -C -d "0-9" <<< "${{ matrix.python-version }}") TOXENV=$(tox --listenvs | grep "^py$ENV_PREFIX" | tr '\n' ',') tox - name: Run lint - if: ${{ matrix.python-version == '3.9' }} + if: ${{ matrix.python-version == '3.12' }} run: | tox -e lint - name: Upload coverage to Codecov diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e9d0aa8..db6300e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -16,6 +16,8 @@ jobs: - '3.8' - '3.9' - '3.10' + - '3.11' + - '3.12' steps: - uses: actions/checkout@v4 @@ -37,7 +39,7 @@ jobs: ENV_PREFIX=$(tr -C -d "0-9" <<< "${{ matrix.python-version }}") TOXENV=$(tox --listenvs | grep "^py$ENV_PREFIX" | tr '\n' ',') tox - name: Run lint - if: ${{ matrix.python-version == '3.9' }} + if: ${{ matrix.python-version == '3.12' }} run: | tox -e lint @@ -49,7 +51,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v3 with: - python-version: '3.9' + python-version: '3.12' - name: Install dependencies run: | pip install build twine diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a1d898..263032c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # CHANGELOG for crispy-tailwind ## Next Release (tbc) +* Added support for Django 5.0 (#142) +* Added support for Python 3.11 and 3.12 (#142) * Added support for Python 3.10 (#116) * Added support for Django 4.2 (#135) * Dropped support for Django 2.2 (#116) diff --git a/crispy_tailwind/templates/tailwind/layout/help_text.html b/crispy_tailwind/templates/tailwind/layout/help_text.html index 486dd5f..7f19ce8 100644 --- a/crispy_tailwind/templates/tailwind/layout/help_text.html +++ b/crispy_tailwind/templates/tailwind/layout/help_text.html @@ -1,7 +1,7 @@ {% if field.help_text %} {% if help_text_inline %} -

{{ field.help_text|safe }}

x +

{{ field.help_text|safe }}

x {% else %} - {{ field.help_text|safe }} + {{ field.help_text|safe }} {% endif %} {% endif %} diff --git a/pyproject.toml b/pyproject.toml index aad21db..f482ed4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,6 +14,7 @@ classifiers=[ "Environment :: Web Environment", "Framework :: Django", "Framework :: Django :: 4.2", + "Framework :: Django :: 5.0", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: JavaScript", @@ -21,6 +22,8 @@ classifiers=[ "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development :: Libraries :: Python Modules", diff --git a/tests/results/filter/crispy_filter.html b/tests/results/filter/crispy_filter.html index 6f16ffa..b3a6027 100644 --- a/tests/results/filter/crispy_filter.html +++ b/tests/results/filter/crispy_filter.html @@ -7,9 +7,9 @@ * - Insert your email + Insert your email
+ +
+ + + Insert your email
+ +
+ + +
+ +
+ +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+
+ +
+ + + +
+
+
+
diff --git a/tests/results/helper/charfield_failing.html b/tests/results/helper/charfield_failing.html index 6e937d6..9f989e3 100644 --- a/tests/results/helper/charfield_failing.html +++ b/tests/results/helper/charfield_failing.html @@ -1,7 +1,7 @@
- +

This field is required.

diff --git a/tests/results/helper/charfield_failing_lt50.html b/tests/results/helper/charfield_failing_lt50.html new file mode 100644 index 0000000..6e937d6 --- /dev/null +++ b/tests/results/helper/charfield_failing_lt50.html @@ -0,0 +1,7 @@ +
+
+ + +

This field is required.

+
+
diff --git a/tests/results/helper/col_row.html b/tests/results/helper/col_row.html index d31c9d5..d594704 100644 --- a/tests/results/helper/col_row.html +++ b/tests/results/helper/col_row.html @@ -33,8 +33,9 @@ class="textinput textInput inputtext border w-full bg-white appearance-none block focus:outline-none leading-normal py-2 border-gray-300 text-gray-700 rounded-lg px-4" required id="id_email" + aria-describedby="id_email_helptext" /> - Insert your email + Insert your email diff --git a/tests/results/helper/col_row_lt50.html b/tests/results/helper/col_row_lt50.html new file mode 100644 index 0000000..0464aff --- /dev/null +++ b/tests/results/helper/col_row_lt50.html @@ -0,0 +1,40 @@ +
+
+
+ + +
+
+ + +
+
+
+
+ + + Insert your email +
+
+
diff --git a/tests/results/helper/div.html b/tests/results/helper/div.html index 85e5518..56ae6c2 100644 --- a/tests/results/helper/div.html +++ b/tests/results/helper/div.html @@ -8,7 +8,8 @@ class="textinput textInput inputtext appearance-none border bg-white focus:outline-none py-2 w-full text-gray-700 border-gray-300 leading-normal block px-4 rounded-lg" required id="id_email" + aria-describedby="id_email_helptext" /> - Insert your email + Insert your email diff --git a/tests/results/helper/div_lt50.html b/tests/results/helper/div_lt50.html new file mode 100644 index 0000000..325b0e9 --- /dev/null +++ b/tests/results/helper/div_lt50.html @@ -0,0 +1,14 @@ +
+
+ + + Insert your email +
+
diff --git a/tests/results/helper/fieldset.html b/tests/results/helper/fieldset.html index 452665c..91ba9aa 100644 --- a/tests/results/helper/fieldset.html +++ b/tests/results/helper/fieldset.html @@ -15,7 +15,8 @@ class="textinput textInput inputtext text-gray-700 py-2 w-full px-4 block focus:outline-none leading-normal bg-white rounded-lg border border-gray-300 appearance-none" required id="id_email" + aria-describedby="id_email_helptext" /> - Insert your email + Insert your email diff --git a/tests/results/helper/fieldset_lt50.html b/tests/results/helper/fieldset_lt50.html new file mode 100644 index 0000000..e4cc8d5 --- /dev/null +++ b/tests/results/helper/fieldset_lt50.html @@ -0,0 +1,21 @@ +
+ Text for the legend +
+ + +
+
+ + + Insert your email +
+
diff --git a/tests/results/helper/formset.html b/tests/results/helper/formset.html index b29a2f4..222ce0d 100644 --- a/tests/results/helper/formset.html +++ b/tests/results/helper/formset.html @@ -10,8 +10,9 @@ maxlength="30" class="textinput textInput inputtext border appearance-none block rounded-lg border-gray-300 px-4 py-2 text-gray-700 w-full leading-normal bg-white focus:outline-none" id="id_form-0-email" + aria-describedby="id_form-0-email_helptext" /> - Insert your email + Insert your email
@@ -21,6 +22,7 @@ maxlength="30" class="textinput textInput inputtext border appearance-none block rounded-lg border-gray-300 px-4 py-2 text-gray-700 w-full leading-normal bg-white focus:outline-none" id="id_form-1-email" + aria-describedby="id_form-1-email_helptext" /> - Insert your email + Insert your email
diff --git a/tests/results/helper/formset_errors.html b/tests/results/helper/formset_errors.html index b34930c..c1d1985 100644 --- a/tests/results/helper/formset_errors.html +++ b/tests/results/helper/formset_errors.html @@ -21,6 +21,7 @@ maxlength="3" class="textinput textInput inputtext leading-normal bg-white w-full focus:outline-none text-gray-700 py-2 appearance-none rounded-lg px-4 block border border-red-500" id="id_name-0-name" + aria-invalid="true" />

Ensure this value has at most 3 characters (it has 4).

diff --git a/tests/results/helper/formset_errors_lt50.html b/tests/results/helper/formset_errors_lt50.html new file mode 100644 index 0000000..b34930c --- /dev/null +++ b/tests/results/helper/formset_errors_lt50.html @@ -0,0 +1,46 @@ +
+ + +
+
+
+ Non Form Errors +
+
+
    +
  • Please submit at most 2 forms.
  • +
+
+
+
+ + +

Ensure this value has at most 3 characters (it has 4).

+
+
+ + +
+
+ + +
diff --git a/tests/results/helper/formset_form_tag.html b/tests/results/helper/formset_form_tag.html index 658af99..cd4aa02 100644 --- a/tests/results/helper/formset_form_tag.html +++ b/tests/results/helper/formset_form_tag.html @@ -11,8 +11,9 @@ maxlength="30" class="textinput textInput inputtext border border-gray-300 py-2 px-4 block rounded-lg appearance-none w-full leading-normal bg-white text-gray-700 focus:outline-none" id="id_form-0-email" + aria-describedby="id_form-0-email_helptext" /> - Insert your email + Insert your email
@@ -22,7 +23,8 @@ maxlength="30" class="textinput textInput inputtext border border-gray-300 py-2 px-4 block rounded-lg appearance-none w-full leading-normal bg-white text-gray-700 focus:outline-none" id="id_form-1-email" + aria-describedby="id_form-1-email_helptext" /> - Insert your email + Insert your email
diff --git a/tests/results/helper/formset_form_tag_lt50.html b/tests/results/helper/formset_form_tag_lt50.html new file mode 100644 index 0000000..1ee96ef --- /dev/null +++ b/tests/results/helper/formset_form_tag_lt50.html @@ -0,0 +1,28 @@ +
+
+ + +
+
+ + + Insert your email +
+
+ + + Insert your email +
+
diff --git a/tests/results/helper/formset_lt50.html b/tests/results/helper/formset_lt50.html new file mode 100644 index 0000000..d71d01f --- /dev/null +++ b/tests/results/helper/formset_lt50.html @@ -0,0 +1,26 @@ +
+ + +
+
+ + + Insert your email +
+
+ + + Insert your email +
diff --git a/tests/results/helper/non_form_errors.html b/tests/results/helper/non_form_errors.html index 93c94aa..7ce8b53 100644 --- a/tests/results/helper/non_form_errors.html +++ b/tests/results/helper/non_form_errors.html @@ -17,6 +17,7 @@ class="passwordinput focus:outline-none rounded-lg border appearance-none text-gray-700 leading-normal block px-4 py-2 w-full bg-white border-red-500" required id="id_password1" + aria-invalid="true" />

This field is required.

@@ -29,6 +30,7 @@ class="passwordinput focus:outline-none rounded-lg border appearance-none text-gray-700 leading-normal block px-4 py-2 w-full bg-white border-red-500" required id="id_password2" + aria-invalid="true" />

This field is required.

diff --git a/tests/results/helper/non_form_errors_lt50.html b/tests/results/helper/non_form_errors_lt50.html new file mode 100644 index 0000000..93c94aa --- /dev/null +++ b/tests/results/helper/non_form_errors_lt50.html @@ -0,0 +1,34 @@ +
+
+ Form Error Title +
+
+
    +
  • Passwords dont match
  • +
+
+
+
+ + +

This field is required.

+
+
+ + +

This field is required.

+
diff --git a/tests/results/prepended/appended_errors.html b/tests/results/prepended/appended_errors.html index 700de40..0314799 100644 --- a/tests/results/prepended/appended_errors.html +++ b/tests/results/prepended/appended_errors.html @@ -1,7 +1,14 @@
- + @
diff --git a/tests/results/prepended/appended_errors_lt50.html b/tests/results/prepended/appended_errors_lt50.html new file mode 100644 index 0000000..700de40 --- /dev/null +++ b/tests/results/prepended/appended_errors_lt50.html @@ -0,0 +1,9 @@ +
+
+
+ + @ +
+
+

This field is required.

+
diff --git a/tests/results/prepended/prepended_appended_errors.html b/tests/results/prepended/prepended_appended_errors.html index 75f4ec8..4342320 100644 --- a/tests/results/prepended/prepended_appended_errors.html +++ b/tests/results/prepended/prepended_appended_errors.html @@ -2,7 +2,14 @@
@ - + .com
diff --git a/tests/results/prepended/prepended_appended_errors_lt50.html b/tests/results/prepended/prepended_appended_errors_lt50.html new file mode 100644 index 0000000..75f4ec8 --- /dev/null +++ b/tests/results/prepended/prepended_appended_errors_lt50.html @@ -0,0 +1,10 @@ +
+
+
+ @ + + .com +
+
+

This field is required.

+
diff --git a/tests/results/prepended/prepended_errors.html b/tests/results/prepended/prepended_errors.html index 57ec73b..01fdd77 100644 --- a/tests/results/prepended/prepended_errors.html +++ b/tests/results/prepended/prepended_errors.html @@ -2,7 +2,14 @@
@ - +

This field is required.

diff --git a/tests/results/prepended/prepended_errors_lt50.html b/tests/results/prepended/prepended_errors_lt50.html new file mode 100644 index 0000000..57ec73b --- /dev/null +++ b/tests/results/prepended/prepended_errors_lt50.html @@ -0,0 +1,9 @@ +
+
+
+ @ + +
+
+

This field is required.

+
diff --git a/tests/results/prepended/prepended_help.html b/tests/results/prepended/prepended_help.html index d980d2a..9b63b83 100644 --- a/tests/results/prepended/prepended_help.html +++ b/tests/results/prepended/prepended_help.html @@ -9,8 +9,9 @@ class="textinput textInput inputtext border border-gray-300 rounded-lg rounded-l-none px-4 py-2 w-full focus:outline-none text-gray-700 border-l-0 leading-normal" required id="id_email" + aria-describedby="id_email_helptext" />
- Insert your email + Insert your email diff --git a/tests/results/prepended/prepended_help_lt50.html b/tests/results/prepended/prepended_help_lt50.html new file mode 100644 index 0000000..c2a53cb --- /dev/null +++ b/tests/results/prepended/prepended_help_lt50.html @@ -0,0 +1,16 @@ +
+
+
+ @ + +
+
+ Insert your email +
diff --git a/tests/results/table_inline_formset/table_inline_formset.html b/tests/results/table_inline_formset/table_inline_formset.html index c34cfc7..fec3594 100644 --- a/tests/results/table_inline_formset/table_inline_formset.html +++ b/tests/results/table_inline_formset/table_inline_formset.html @@ -27,8 +27,9 @@ maxlength="30" class="textinput textInput inputtext w-full border border-gray-300 focus:outline-none text-gray-700 px-4 bg-white leading-normal rounded-lg block py-2 appearance-none" id="id_form-0-email" + aria-describedby="id_form-0-email_helptext" /> - Insert your email + Insert your email - Insert your email + Insert your email - +

Ensure this value has at most 3 characters (it has 4).

diff --git a/tests/results/table_inline_formset/table_inline_formset_failing_lt50.html b/tests/results/table_inline_formset/table_inline_formset_failing_lt50.html new file mode 100644 index 0000000..7b5461f --- /dev/null +++ b/tests/results/table_inline_formset/table_inline_formset_failing_lt50.html @@ -0,0 +1,36 @@ +
+
+
+
+
    +
  • Please submit at most 2 forms.
  • +
+
+
+ + + + + + + + + + + + + + + + + +
+ Name*
+

Ensure this value has at most 3 characters (it has 4).

+
+
+
+
+
+
+
diff --git a/tests/results/table_inline_formset/table_inline_formset_lt50.html b/tests/results/table_inline_formset/table_inline_formset_lt50.html new file mode 100644 index 0000000..20ed633 --- /dev/null +++ b/tests/results/table_inline_formset/table_inline_formset_lt50.html @@ -0,0 +1,179 @@ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ company + email*password*re-enter password*first name*last name*date time*terms of service*
+ + Insert your email + + + + + + + + + + + + +
+
+ +
+ +
+
+
+
+ + Insert your email + + + + + + + + + + + + +
+
+ +
+ +
+
+
+
+
+
+
+
+
diff --git a/tests/test_filter.py b/tests/test_filter.py index dcd7f83..5758192 100644 --- a/tests/test_filter.py +++ b/tests/test_filter.py @@ -1,3 +1,4 @@ +import django from django.forms.models import formset_factory from django.template import Context, Template from django.test import SimpleTestCase @@ -20,7 +21,11 @@ def test_crispy_filter(self): form = SampleForm() c = Context({"form": form}) html = template.render(c) - assert parse_html(html) == parse_expected("filter/crispy_filter.html") + if django.VERSION < (5, 0): + expected = "filter/crispy_filter_lt50.html" + else: + expected = "filter/crispy_filter.html" + assert parse_html(html) == parse_expected(expected) def test_error_borders(self): template = Template( diff --git a/tests/test_helper.py b/tests/test_helper.py index 31e6727..6e52a3e 100644 --- a/tests/test_helper.py +++ b/tests/test_helper.py @@ -1,3 +1,4 @@ +import django from django.forms.models import formset_factory from django.template import Template from django.test import SimpleTestCase @@ -38,7 +39,11 @@ def test_CharField(self): def test_failing_CharField(self): form = CharFieldForm(data={"name": ""}) form.helper = FormHelper() - assert parse_form(form) == parse_expected("helper/charfield_failing.html") + if django.VERSION < (5, 0): + expected = "helper/charfield_failing_lt50.html" + else: + expected = "helper/charfield_failing.html" + assert parse_form(form) == parse_expected(expected) def test_password(self): form = PasswordFieldForm() @@ -74,7 +79,11 @@ def test_col_row(self): Column("email", css_class="px-2"), ) ) - assert parse_form(form) == parse_expected("helper/col_row.html") + if django.VERSION < (5, 0): + expected = "helper/col_row_lt50.html" + else: + expected = "helper/col_row.html" + assert parse_form(form) == parse_expected(expected) def test_inline_radio(self): form = RadioForm() @@ -96,7 +105,11 @@ def test_formset(self): formset.helper = FormHelper() formset.helper.form_tag = False formset.helper.layout = Layout("email") - assert parse_form(formset) == parse_expected("helper/formset.html") + if django.VERSION < (5, 0): + expected = "helper/formset_lt50.html" + else: + expected = "helper/formset.html" + assert parse_form(formset) == parse_expected(expected) def test_formset_with_errors(self): SampleFormSet = formset_factory(ShortCharFieldForm, extra=1, max_num=2, validate_max=True) @@ -112,7 +125,11 @@ def test_formset_with_errors(self): formset.helper.formset_error_title = "Non Form Errors" formset.helper.form_tag = False formset.helper.layout = Layout("email") - assert parse_form(formset) == parse_expected("helper/formset_errors.html") + if django.VERSION < (5, 0): + expected = "helper/formset_errors_lt50.html" + else: + expected = "helper/formset_errors.html" + assert parse_form(formset) == parse_expected(expected) def test_formset_with_form_tag(self): SampleFormSet = formset_factory(SampleForm, extra=2) @@ -120,7 +137,11 @@ def test_formset_with_form_tag(self): formset.helper = FormHelper() formset.helper.form_tag = True formset.helper.layout = Layout("email") - assert parse_form(formset) == parse_expected("helper/formset_form_tag.html") + if django.VERSION < (5, 0): + expected = "helper/formset_form_tag_lt50.html" + else: + expected = "helper/formset_form_tag.html" + assert parse_form(formset) == parse_expected(expected) def test_buttons(self): form = CharFieldForm() @@ -150,7 +171,11 @@ def test_div(self): form.helper = FormHelper() form.helper.form_tag = False form.helper.layout = Layout(Div("email", "name", css_class="test class")) - assert parse_form(form) == parse_expected("helper/div.html") + if django.VERSION < (5, 0): + expected = "helper/div_lt50.html" + else: + expected = "helper/div.html" + assert parse_form(form) == parse_expected(expected) def test_HTML(self): form = CharFieldForm() @@ -181,7 +206,11 @@ def test_fieldset(self): "email", ) ) - assert parse_form(form) == parse_expected("helper/fieldset.html") + if django.VERSION < (5, 0): + expected = "helper/fieldset_lt50.html" + else: + expected = "helper/fieldset.html" + assert parse_form(form) == parse_expected(expected) def test_non_form_errors(self): form = SampleForm(data={}) @@ -189,7 +218,11 @@ def test_non_form_errors(self): form.helper.form_tag = False form.helper.form_error_title = "Form Error Title" form.helper.layout = Layout("password1", "password2") - assert parse_form(form) == parse_expected("helper/non_form_errors.html") + if django.VERSION < (5, 0): + expected = "helper/non_form_errors_lt50.html" + else: + expected = "helper/non_form_errors.html" + assert parse_form(form) == parse_expected(expected) def test_select(self): form = SelectForm(data={"tos_accepted": "accepted"}) diff --git a/tests/test_prepended_appended.py b/tests/test_prepended_appended.py index b8087e5..72685f5 100644 --- a/tests/test_prepended_appended.py +++ b/tests/test_prepended_appended.py @@ -1,3 +1,4 @@ +import django from django.template import Template from django.test import SimpleTestCase @@ -61,7 +62,11 @@ def test_prepended_with_help(self): form.helper.form_tag = False form.helper.form_show_labels = False form.helper.layout = Layout(PrependedText("email", "@")) - assert parse_form(form) == parse_expected("prepended/prepended_help.html") + if django.VERSION < (5, 0): + expected = "prepended/prepended_help_lt50.html" + else: + expected = "prepended/prepended_help.html" + assert parse_form(form) == parse_expected(expected) def test_prepended_with_errors(self): form = CharFieldForm(data={"name": ""}) @@ -69,7 +74,11 @@ def test_prepended_with_errors(self): form.helper.form_tag = False form.helper.form_show_labels = False form.helper.layout = Layout(PrependedText("name", "@")) - assert parse_form(form) == parse_expected("prepended/prepended_errors.html") + if django.VERSION < (5, 0): + expected = "prepended/prepended_errors_lt50.html" + else: + expected = "prepended/prepended_errors.html" + assert parse_form(form) == parse_expected(expected) def test_appended_with_errors(self): form = CharFieldForm(data={"name": ""}) @@ -77,7 +86,11 @@ def test_appended_with_errors(self): form.helper.form_tag = False form.helper.form_show_labels = False form.helper.layout = Layout(AppendedText("name", "@")) - assert parse_form(form) == parse_expected("prepended/appended_errors.html") + if django.VERSION < (5, 0): + expected = "prepended/appended_errors_lt50.html" + else: + expected = "prepended/appended_errors.html" + assert parse_form(form) == parse_expected(expected) def test_prepended_and_appended_with_errors(self): form = CharFieldForm(data={"name": ""}) @@ -85,4 +98,8 @@ def test_prepended_and_appended_with_errors(self): form.helper.form_tag = False form.helper.form_show_labels = False form.helper.layout = Layout(PrependedAppendedText("name", "@", ".com")) - assert parse_form(form) == parse_expected("prepended/prepended_appended_errors.html") + if django.VERSION < (5, 0): + expected = "prepended/prepended_appended_errors_lt50.html" + else: + expected = "prepended/prepended_appended_errors.html" + assert parse_form(form) == parse_expected(expected) diff --git a/tests/test_table_inline_formset.py b/tests/test_table_inline_formset.py index dddfa9c..31d0469 100644 --- a/tests/test_table_inline_formset.py +++ b/tests/test_table_inline_formset.py @@ -1,3 +1,4 @@ +import django from django.forms import formset_factory from django.test import SimpleTestCase @@ -18,7 +19,11 @@ def test_table_inline_formset(self): formset.helper.form_tag = False formset.helper.add_input(Submit("submit", "submit")) formset.helper.template = "tailwind/table_inline_formset.html" - assert parse_form(formset) == parse_expected("table_inline_formset/table_inline_formset.html") + if django.VERSION < (5, 0): + expected = "table_inline_formset/table_inline_formset_lt50.html" + else: + expected = "table_inline_formset/table_inline_formset.html" + assert parse_form(formset) == parse_expected(expected) def test_failing_table_inline_formset(self): SampleFormSet = formset_factory(ShortCharFieldForm, extra=1, max_num=2, validate_max=True) @@ -34,4 +39,8 @@ def test_failing_table_inline_formset(self): formset.helper = FormHelper() formset.helper.add_input(Submit("submit", "submit")) formset.helper.template = "tailwind/table_inline_formset.html" - assert parse_form(formset) == parse_expected("table_inline_formset/table_inline_formset_failing.html") + if django.VERSION < (5, 0): + expected = "table_inline_formset/table_inline_formset_failing_lt50.html" + else: + expected = "table_inline_formset/table_inline_formset_failing.html" + assert parse_form(formset) == parse_expected(expected) diff --git a/tox.ini b/tox.ini index fc3a9f9..fb8a563 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,7 @@ [tox] envlist = {py38,py39,py310,py311}-django{42}-crispy{2,-latest}, + {py310,py311,py312}-django{50}-crispy{2,-latest}, lint [testenv]