diff --git a/tests/test_forms.py b/tests/test_forms.py
index 3cefda0f..622991ef 100644
--- a/tests/test_forms.py
+++ b/tests/test_forms.py
@@ -29,22 +29,15 @@ def test_show_help(self):
res = render_form_field("subject")
self.assertIn("my_help_text", res)
self.assertNotIn("my_help_text", res)
- res = render_template_with_form(
- "{% bootstrap_field form.subject show_help=0 %}"
- )
+ res = render_template_with_form("{% bootstrap_field form.subject show_help=0 %}")
self.assertNotIn("my_help_text", res)
def test_help_with_quotes(self):
# Checkboxes get special handling, so test a checkbox and something else
res = render_form_field("sender")
- self.assertIn(
- 'title="{}"'.format(escape(TestForm.base_fields["sender"].help_text)), res
- )
+ self.assertIn('title="{}"'.format(escape(TestForm.base_fields["sender"].help_text)), res)
res = render_form_field("cc_myself")
- self.assertIn(
- 'title="{}"'.format(escape(TestForm.base_fields["cc_myself"].help_text)),
- res,
- )
+ self.assertIn('title="{}"'.format(escape(TestForm.base_fields["cc_myself"].help_text)), res)
def test_subject(self):
res = render_form_field("subject")
@@ -61,12 +54,7 @@ def test_xss_field(self):
),
res,
)
- self.assertIn(
- (
- 'placeholder="XSS" onmouseover="alert('Hello, XSS')" foo=""'
- ),
- res,
- )
+ self.assertIn(('placeholder="XSS" onmouseover="alert('Hello, XSS')" foo=""'), res)
def test_password(self):
res = render_form_field("password")
@@ -97,8 +85,7 @@ def test_radio_select(self):
)
if DJANGO_VERSION >= 4:
expected_html = expected_html.replace(
- '',
- "",
+ '', ""
)
self.assertHTMLEqual(res, expected_html)
@@ -108,49 +95,23 @@ def test_checkbox(self):
# strip out newlines and spaces around newlines
res = "".join(line.strip() for line in res.split("\n"))
res = BeautifulSoup(res, "html.parser")
- form_group = self._select_one_element(
- res, ".form-group", "Checkbox should be rendered inside a .form-group."
- )
+ form_group = self._select_one_element(res, ".form-group", "Checkbox should be rendered inside a .form-group.")
form_check = self._select_one_element(
- form_group,
- ".form-check",
- "There should be a .form-check inside .form-group",
+ form_group, ".form-check", "There should be a .form-check inside .form-group"
)
- checkbox = self._select_one_element(
- form_check, "input", "The checkbox should be inside the .form-check"
- )
- self.assertIn(
- "form-check-input",
- checkbox["class"],
- "The checkbox should have the class 'form-check-input'.",
- )
- label = checkbox.next_sibling
+ checkbox = self._select_one_element(form_check, "input", "The checkbox should be inside the .form-check")
+ self.assertIn("form-check-input", checkbox["class"], "The checkbox should have the class 'form-check-input'.")
+ label = checkbox.nextSibling
self.assertIsNotNone(label, "The label should be rendered after the checkbox.")
+ self.assertEqual(label.name, "label", "After the checkbox there should be a label.")
self.assertEqual(
- label.name, "label", "After the checkbox there should be a label."
- )
- self.assertEqual(
- label["for"],
- checkbox["id"],
- "The for attribute of the label should be the id of the checkbox.",
- )
- help_text = label.next_sibling
- self.assertIsNotNone(
- help_text, "The help text should be rendered after the label."
- )
- self.assertEqual(
- help_text.name, "small", "The help text should be rendered as tag."
- )
- self.assertIn(
- "form-text",
- help_text["class"],
- "The help text should have the class 'form-text'.",
- )
- self.assertIn(
- "text-muted",
- help_text["class"],
- "The help text should have the class 'text-muted'.",
+ label["for"], checkbox["id"], "The for attribute of the label should be the id of the checkbox."
)
+ help_text = label.nextSibling
+ self.assertIsNotNone(help_text, "The help text should be rendered after the label.")
+ self.assertEqual(help_text.name, "small", "The help text should be rendered as tag.")
+ self.assertIn("form-text", help_text["class"], "The help text should have the class 'form-text'.")
+ self.assertIn("text-muted", help_text["class"], "The help text should have the class 'text-muted'.")
def test_checkbox_multiple_select(self):
res = render_form_field("category2")
@@ -187,9 +148,7 @@ def test_required_field(self):
# Required settings in field
form_field = "form.subject"
rendered = render_template_with_form(
- "{% bootstrap_field "
- + form_field
- + ' required_css_class="test-required" %}'
+ "{% bootstrap_field " + form_field + ' required_css_class="test-required" %}'
)
self.assertIn("test-required", rendered)
@@ -204,16 +163,10 @@ def test_empty_permitted(self):
self.assertNotIn(required_css_class, res)
def test_input_group(self):
- res = render_template_with_form(
- '{% bootstrap_field form.subject addon_before="$" addon_after=".00" %}'
- )
+ res = render_template_with_form('{% bootstrap_field form.subject addon_before="$" addon_after=".00" %}')
self.assertIn('class="input-group"', res)
- self.assertIn(
- 'class="input-group-prepend">$', res
- )
- self.assertIn(
- 'class="input-group-append">.00', res
- )
+ self.assertIn('class="input-group-prepend">$', res)
+ self.assertIn('class="input-group-append">.00', res)
def test_input_group_addon_button(self):
res = render_template_with_form(
@@ -227,15 +180,10 @@ def test_input_group_addon_button(self):
self.assertIn('