Closed justinmayer closed 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?
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>
~
@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?
Agreed — I think iterative improvement are always best. 💫
I just remembered we need to update the classifiers in setup.py
as well.
Sorry.
Merging #91 (2791007) into main (5ea1042) will increase coverage by
0.31%
. The diff coverage isn/a
.
@@ 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.
This PR contains a few minor CI-related changes: