diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 24b700d..eddc4d4 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -12,7 +12,6 @@ jobs: strategy: matrix: python-version: - - '3.7' - '3.8' - '3.9' - '3.10' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b2e043c..c90ba4d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,6 @@ jobs: strategy: matrix: python-version: - - '3.7' - '3.8' - '3.9' - '3.10' diff --git a/tests/results/bootstrap3/test_form_helper/bootstrap_form_show_errors_bs3_false_gte50.html b/tests/results/bootstrap3/test_form_helper/bootstrap_form_show_errors_bs3_false_gte50.html new file mode 100644 index 0000000..aaa0c50 --- /dev/null +++ b/tests/results/bootstrap3/test_form_helper/bootstrap_form_show_errors_bs3_false_gte50.html @@ -0,0 +1,45 @@ +
diff --git a/tests/results/bootstrap3/test_form_helper/bootstrap_form_show_errors_bs3_true_gte50.html b/tests/results/bootstrap3/test_form_helper/bootstrap_form_show_errors_bs3_true_gte50.html new file mode 100644 index 0000000..2d9cbdd --- /dev/null +++ b/tests/results/bootstrap3/test_form_helper/bootstrap_form_show_errors_bs3_true_gte50.html @@ -0,0 +1,49 @@ + diff --git a/tests/results/bootstrap3/test_form_helper/test_form_show_errors_non_field_errors_false_gte50.html b/tests/results/bootstrap3/test_form_helper/test_form_show_errors_non_field_errors_false_gte50.html new file mode 100644 index 0000000..e07180f --- /dev/null +++ b/tests/results/bootstrap3/test_form_helper/test_form_show_errors_non_field_errors_false_gte50.html @@ -0,0 +1,40 @@ + \ No newline at end of file diff --git a/tests/results/bootstrap3/test_form_helper/test_form_show_errors_non_field_errors_true_gte50.html b/tests/results/bootstrap3/test_form_helper/test_form_show_errors_non_field_errors_true_gte50.html new file mode 100644 index 0000000..6a265d0 --- /dev/null +++ b/tests/results/bootstrap3/test_form_helper/test_form_show_errors_non_field_errors_true_gte50.html @@ -0,0 +1,49 @@ + \ No newline at end of file diff --git a/tests/results/bootstrap3/test_layout/test_layout_composition_gte50.html b/tests/results/bootstrap3/test_layout/test_layout_composition_gte50.html new file mode 100644 index 0000000..594b99f --- /dev/null +++ b/tests/results/bootstrap3/test_layout/test_layout_composition_gte50.html @@ -0,0 +1,35 @@ + \ No newline at end of file diff --git a/tests/results/bootstrap3/test_layout/test_second_layout_multifield_column_buttonholder_submit_div_gte50.html b/tests/results/bootstrap3/test_layout/test_second_layout_multifield_column_buttonholder_submit_div_gte50.html new file mode 100644 index 0000000..a4d6712 --- /dev/null +++ b/tests/results/bootstrap3/test_layout/test_second_layout_multifield_column_buttonholder_submit_div_gte50.html @@ -0,0 +1,41 @@ + \ No newline at end of file diff --git a/tests/results/bootstrap3/test_layout_objects/test_prepended_appended_text_gte50.html b/tests/results/bootstrap3/test_layout_objects/test_prepended_appended_text_gte50.html new file mode 100644 index 0000000..304961d --- /dev/null +++ b/tests/results/bootstrap3/test_layout_objects/test_prepended_appended_text_gte50.html @@ -0,0 +1,37 @@ + \ No newline at end of file diff --git a/tests/test_form_helper.py b/tests/test_form_helper.py index 5acad89..f54f234 100644 --- a/tests/test_form_helper.py +++ b/tests/test_form_helper.py @@ -139,6 +139,13 @@ def test_form_show_errors_non_field_errors(): "bootstrap3/test_form_helper/" "test_form_show_errors_non_field_errors_true_lte40.html" ) + elif django.VERSION >= (5, 0): + # Added 'aria-describedby' for fields with help_text + # https://docs.djangoproject.com/en/5.0/releases/5.0/#forms + expected = parse_expected( + "bootstrap3/test_form_helper/" + "test_form_show_errors_non_field_errors_true_gte50.html" + ) else: expected = parse_expected( "bootstrap3/test_form_helper/" @@ -155,6 +162,13 @@ def test_form_show_errors_non_field_errors(): "bootstrap3/test_form_helper/" "test_form_show_errors_non_field_errors_false_lte40.html" ) + elif django.VERSION >= (5, 0): + # Added 'aria-describedby' for fields with help_text + # https://docs.djangoproject.com/en/5.0/releases/5.0/#forms + expected = parse_expected( + "bootstrap3/test_form_helper/" + "test_form_show_errors_non_field_errors_false_gte50.html" + ) else: expected = parse_expected( "bootstrap3/test_form_helper/" @@ -528,14 +542,31 @@ def test_bootstrap_form_show_errors_bs3(): form.is_valid() form.helper.form_show_errors = True - assert parse_form(form) == parse_expected( - "bootstrap3/test_form_helper/bootstrap_form_show_errors_bs3_true.html" - ) + if django.VERSION >= (5, 0): + # Added 'aria-describedby' for fields with help_text + # https://docs.djangoproject.com/en/5.0/releases/5.0/#forms + expected = parse_expected( + "bootstrap3/test_form_helper/bootstrap_form_show_errors_bs3_true_gte50.html" + ) + else: + expected = parse_expected( + "bootstrap3/test_form_helper/bootstrap_form_show_errors_bs3_true.html" + ) + assert parse_form(form) == expected form.helper.form_show_errors = False - assert parse_form(form) == parse_expected( - "bootstrap3/test_form_helper/bootstrap_form_show_errors_bs3_false.html" - ) + if django.VERSION >= (5, 0): + # Added 'aria-describedby' for fields with help_text + # https://docs.djangoproject.com/en/5.0/releases/5.0/#forms + expected = parse_expected( + "bootstrap3/test_form_helper/" + "bootstrap_form_show_errors_bs3_false_gte50.html" + ) + else: + expected = parse_expected( + "bootstrap3/test_form_helper/bootstrap_form_show_errors_bs3_false.html" + ) + assert parse_form(form) == expected def test_error_text_inline(settings): diff --git a/tests/test_layout.py b/tests/test_layout.py index 2ec37be..8e5855c 100644 --- a/tests/test_layout.py +++ b/tests/test_layout.py @@ -1,3 +1,4 @@ +import django import pytest from crispy_forms import __version__ from crispy_forms.bootstrap import Field, InlineCheckboxes @@ -462,9 +463,15 @@ def test_layout_composition(settings): html = template.render(c) # Bootstrap 4 does not contain a multifield template - assert parse_html(html) == parse_expected( - "bootstrap3/test_layout/test_layout_composition.html" - ) + if django.VERSION >= (5, 0): + # Added 'aria-describedby' for fields with help_text + # https://docs.djangoproject.com/en/5.0/releases/5.0/#forms + expected = parse_expected( + "bootstrap3/test_layout/test_layout_composition_gte50.html" + ) + else: + expected = parse_expected("bootstrap3/test_layout/test_layout_composition.html") + assert parse_html(html) == expected @override_settings(CRISPY_CLASS_CONVERTERS=CONVERTERS) @@ -516,10 +523,19 @@ def test_second_layout_multifield_column_buttonholder_submit_div(settings): html = template.render(c) # Bootstrap 4 does not contain a multifield template - assert parse_html(html) == parse_expected( - "bootstrap3/test_layout/" - "test_second_layout_multifield_column_buttonholder_submit_div.html" - ) + if django.VERSION >= (5, 0): + # Added 'aria-describedby' for fields with help_text + # https://docs.djangoproject.com/en/5.0/releases/5.0/#forms + expected = parse_expected( + "bootstrap3/test_layout/" + "test_second_layout_multifield_column_buttonholder_submit_div_gte50.html" + ) + else: + expected = parse_expected( + "bootstrap3/test_layout/" + "test_second_layout_multifield_column_buttonholder_submit_div.html" + ) + assert parse_html(html) == expected @override_settings( diff --git a/tests/test_layout_objects.py b/tests/test_layout_objects.py index d4c7df1..861a7f7 100644 --- a/tests/test_layout_objects.py +++ b/tests/test_layout_objects.py @@ -1,3 +1,4 @@ +import django import pytest from crispy_forms import __version__ from crispy_forms.bootstrap import ( @@ -162,7 +163,6 @@ def test_remove_labels(): class TestBootstrapLayoutObjects: def test_custom_django_widget(self): - # Make sure an inherited RadioSelect gets rendered as it form = SampleFormCustomWidgets() assert isinstance(form.fields["inline_radios"].widget, CustomRadioSelect) @@ -191,9 +191,17 @@ def test_prepended_appended_text(self): AppendedText("password1", "#", css_class="input-lg"), PrependedText("password2", "$", css_class="input-sm"), ) - assert parse_form(test_form) == parse_expected( - "bootstrap3/test_layout_objects/test_prepended_appended_text.html" - ) + if django.VERSION >= (5, 0): + # Added 'aria-describedby' for fields with help_text + # https://docs.djangoproject.com/en/5.0/releases/5.0/#forms + expected = parse_expected( + "bootstrap3/test_layout_objects/test_prepended_appended_text_gte50.html" + ) + else: + expected = parse_expected( + "bootstrap3/test_layout_objects/test_prepended_appended_text.html" + ) + assert parse_form(test_form) == expected def test_inline_radios(self): test_form = CheckboxesSampleForm() diff --git a/tox.ini b/tox.ini index acb7fec..a8150a3 100644 --- a/tox.ini +++ b/tox.ini @@ -1,16 +1,17 @@ [tox] envlist = - {py37,py38,py39,py310}-django{32}-crispy{1,-latest}, - {py38,py39,py310}-django{40,41,-latest}-crispy{1,-latest}, - {py311}-django{41,-latest}-crispy{1,-latest}, + {py38,py39,py310}-django32-crispy1, + {py38,py39,py310}-django42-crispy{1,2,-latest}, + {py311}-django{42,50}-crispy{2,-latest}, lint [testenv] deps = - django32: django>=3.2,<3.3 - django40: django>=4.0a,<4.1 - django41: django>=4.1a,<4.2 + django32: django>=3.2,<4 + django42: django>=4.2,<5 + django50: django>=5.0,<5.1 crispy1: django-crispy-forms<=2.0 + crispy2: django-crispy-forms>=2.0,<3 crispy-latest: https://github.com/django-crispy-forms/django-crispy-forms/archive/main.tar.gz -rrequirements/testing.txt commands = python -W error::DeprecationWarning -W error::PendingDeprecationWarning -m pytest {posargs}