django-crispy-forms / crispy-tailwind

A Tailwind template pack for django-crispy-forms
MIT License
331 stars 56 forks source link

Add Django 3.2 to CI test matrix and remove 3.0 #91

Closed justinmayer closed 3 years ago

justinmayer commented 3 years ago

This PR contains a few minor CI-related changes:

justinmayer commented 3 years ago

How fun… The form validation failure error message changed between Django 2.2 and 3.1, so updating it for 3.1+ obviously causes the test to fail for Django 2.2. Anyone have suggestions regarding how to make that test compatible with multiple Django versions?

smithdc1 commented 3 years ago

What do you think about something like this?

diff --git a/tests/test_helper.py b/tests/test_helper.py
index b141bb1..addd9ca 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
@@ -303,6 +304,8 @@ class CrispyHelperTests(SimpleTestCase):
         formset.helper.formset_error_title = "Non Form Errors"
         formset.helper.form_tag = False
         formset.helper.layout = Layout("email")
+        if django.VERSION < (3, 2):
+            formset.non_form_errors = ["Please submit at most 2 forms."]
         html = render_crispy_form(formset)
         expected_html = """
             <div>
@@ -315,7 +318,7 @@ class CrispyHelperTests(SimpleTestCase):
                 </div>
                 <div class="border border-red-400 rounded-b bg-red-100 px-4 py-3 text-red-700">
                     <ul>
-                        <li>Please submit 2 or fewer forms.</li>
+                        <li>Please submit at most 2 forms.</li>
                     </ul>
                 </div>
             </div>
~
justinmayer commented 3 years ago

@smithdc1: Good suggestion. Thanks for that. I changed the test code here accordingly, and everything looks to be in good shape now, with all tests passing. Would you mind having another look and then merging if everything seems to be in order?

justinmayer commented 3 years ago

Agreed — I think iterative improvement are always best. 💫

smithdc1 commented 3 years ago

I just remembered we need to update the classifiers in setup.py as well.

Sorry.

codecov-io commented 3 years ago

Codecov Report

Merging #91 (2791007) into main (5ea1042) will increase coverage by 0.31%. The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #91      +/-   ##
==========================================
+ Coverage   70.80%   71.11%   +0.31%     
==========================================
  Files          37       37              
  Lines         637      637              
  Branches       28       28              
==========================================
+ Hits          451      453       +2     
+ Misses        176      174       -2     
  Partials       10       10              
Impacted Files Coverage Δ
crispy_tailwind/templatetags/tailwind_field.py 48.62% <0.00%> (+1.83%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 5ea1042...2791007. Read the comment docs.