summaryrefslogtreecommitdiff
path: root/dev-python/crispy-bootstrap5/files/crispy-bootstrap5-0.7-test.patch
blob: 914b483854372bd6124f4b23dcd6db2ce93afd9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
From 69ff88bed286a76e6216a54ecf93a0b27d87bc8d Mon Sep 17 00:00:00 2001
From: David Smith <39445562+smithdc1@users.noreply.github.com>
Date: Thu, 15 Dec 2022 08:01:04 +0000
Subject: [PATCH] Fixed tests for crispy-forms 2.x (#133)

---
 tests/templates/custom_field_template.html         |  2 +-
 tests/templates/custom_form_template.html          |  2 +-
 .../custom_form_template_with_context.html         |  2 +-
 tests/test_layout.py                               | 14 ++++++++++++--
 tests/test_layout_objects.py                       | 12 ++++++++++++
 tox.ini                                            |  2 --
 6 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/tests/templates/custom_field_template.html b/tests/templates/custom_field_template.html
index 4724226..04f0274 100644
--- a/tests/templates/custom_field_template.html
+++ b/tests/templates/custom_field_template.html
@@ -1,2 +1,2 @@
 <h1>Special custom field</h1>
-{% include 'bootstrap/field.html' %}
+{% include 'bootstrap5/field.html' %}
diff --git a/tests/templates/custom_form_template.html b/tests/templates/custom_form_template.html
index f2da757..c09b4c7 100644
--- a/tests/templates/custom_form_template.html
+++ b/tests/templates/custom_form_template.html
@@ -1,2 +1,2 @@
 <h1>Special custom form</h1>
-{% include "bootstrap/whole_uni_form.html" %}
+{% include "bootstrap5/whole_uni_form.html" %}
diff --git a/tests/templates/custom_form_template_with_context.html b/tests/templates/custom_form_template_with_context.html
index 2378296..477997a 100644
--- a/tests/templates/custom_form_template_with_context.html
+++ b/tests/templates/custom_form_template_with_context.html
@@ -1,4 +1,4 @@
 <h1>Special custom form with context passthrough</h1>
 Got prefix: {{ prefix }}.
-{% include "bootstrap/whole_uni_form.html" %}
+{% include "bootstrap5/whole_uni_form.html" %}
 Got suffix: {{ suffix }}.
diff --git a/tests/test_layout.py b/tests/test_layout.py
index 512facf..a2a72e8 100644
--- a/tests/test_layout.py
+++ b/tests/test_layout.py
@@ -16,6 +16,7 @@
 from django.middleware.csrf import _get_new_csrf_string
 from django.shortcuts import render
 from django.template import Context, Template
+from django.test import override_settings
 from django.urls import reverse
 from django.utils.translation import gettext_lazy as _
 
@@ -36,6 +37,12 @@
 )
 from .utils import contains_partial, parse_expected, parse_form
 
+CONVERTERS = {
+    "textinput": "inputtext textinput textInput",
+    "fileinput": "fileinput fileUpload",
+    "passwordinput": "textinput textInput",
+}
+
 
 def test_invalid_unicode_characters(settings):
     # Adds a BooleanField that uses non valid unicode characters "ñ"
@@ -331,6 +338,7 @@ def test_bs5_field_with_buttons_css_classes():
     assert parse_form(form) == parse_expected("field_with_buttons_failing.html")
 
 
+@override_settings(CRISPY_CLASS_CONVERTERS=CONVERTERS)
 def test_formset_layout():
     SampleFormSet = formset_factory(SampleForm, extra=3)
     formset = SampleFormSet()
@@ -523,6 +531,7 @@ def test_keepcontext_context_manager():
     assert response.content.count(b"form-check-input") > 0
 
 
+@override_settings(CRISPY_CLASS_CONVERTERS=CONVERTERS)
 def test_bootstrap5_form_inline():
     form = SampleForm()
     form.helper = FormHelper()
@@ -557,7 +566,7 @@ def test_update_attributes_class():
     form.helper.layout = Layout("email", Field("password1"), "password2")
     form.helper["password1"].update_attributes(css_class="hello")
     html = render_crispy_form(form)
-    assert html.count(' class="hello textinput') == 1
+    assert html.count(' class="hello') == 1
     form.helper = FormHelper()
     form.helper.layout = Layout(
         "email",
@@ -566,7 +575,7 @@ def test_update_attributes_class():
     )
     form.helper["password1"].update_attributes(css_class="hello2")
     html = render_crispy_form(form)
-    assert html.count(' class="hello hello2 textinput') == 1
+    assert html.count(' class="hello hello2') == 1
 
 
 def test_file_field():
@@ -611,6 +620,7 @@ def test_html_label_escape():
     assert "&lt;&gt;&amp;" in html
 
 
+@override_settings(CRISPY_CLASS_CONVERTERS=CONVERTERS)
 def test_tabular_formset_layout():
     SampleFormSet = formset_factory(SampleForm, extra=3)
     formset = SampleFormSet()
diff --git a/tests/test_layout_objects.py b/tests/test_layout_objects.py
index b386c0b..0e3dde7 100644
--- a/tests/test_layout_objects.py
+++ b/tests/test_layout_objects.py
@@ -21,6 +21,7 @@
 from crispy_forms.utils import render_crispy_form
 from django import forms
 from django.template import Context, Template
+from django.test import override_settings
 from django.utils.translation import activate, deactivate
 from django.utils.translation import gettext as _
 
@@ -37,6 +38,12 @@
 )
 from .utils import parse_expected, parse_form
 
+CONVERTERS = {
+    "textinput": "inputtext textinput textInput",
+    "fileinput": "fileinput fileUpload",
+    "passwordinput": "textinput textInput",
+}
+
 
 def test_field_with_custom_template():
     test_form = SampleForm()
@@ -202,6 +209,7 @@ def test_custom_django_widget(self):
         html = render_crispy_form(form)
         assert 'class="form-check-input"' in html
 
+    @override_settings(CRISPY_CLASS_CONVERTERS=CONVERTERS)
     def test_prepended_appended_text(self):
         test_form = SampleForm()
         test_form.helper = FormHelper()
@@ -223,6 +231,7 @@ def test_inline_radios(self):
         html = render_crispy_form(test_form)
         assert html.count('form-check-inline"') == 2
 
+    @override_settings(CRISPY_CLASS_CONVERTERS=CONVERTERS)
     def test_accordion_and_accordiongroup(self):
         random.seed(0)
         form = SampleForm()
@@ -269,6 +278,7 @@ def test_accordion_active_false_not_rendered(self):
             == 0
         )
 
+    @override_settings(CRISPY_CLASS_CONVERTERS=CONVERTERS)
     def test_bs5accordion(self):
         random.seed(0)
         form = SampleForm()
@@ -315,6 +325,7 @@ def test_bs5accordion_active_false_not_rendered(self):
             == 0
         )
 
+    @override_settings(CRISPY_CLASS_CONVERTERS=CONVERTERS)
     def test_bs5accordion_flush(self):
         random.seed(0)
         test_form = SampleForm()
@@ -329,6 +340,7 @@ def test_bs5accordion_flush(self):
         )
         assert parse_form(test_form) == parse_expected("accordion_flush.html")
 
+    @override_settings(CRISPY_CLASS_CONVERTERS=CONVERTERS)
     def test_bs5accordion_always_open(self):
         random.seed(0)
         test_form = SampleForm()