From 3278c31fa59b41d03aea167f4cf85f4ddf7f848d Mon Sep 17 00:00:00 2001
From: Mariusz Felisiak '
- '
+
+
""",
)
diff --git a/tests/forms_tests/field_tests/test_nullbooleanfield.py b/tests/forms_tests/field_tests/test_nullbooleanfield.py
index 5b632c8de3..c1e120c0bb 100644
--- a/tests/forms_tests/field_tests/test_nullbooleanfield.py
+++ b/tests/forms_tests/field_tests/test_nullbooleanfield.py
@@ -27,9 +27,11 @@ class NullBooleanFieldTest(FormFieldAssertionsMixin, SimpleTestCase):
f = HiddenNullBooleanForm()
self.assertHTMLEqual(
- ''
- '',
str(f),
+ ''
+ '',
)
def test_nullbooleanfield_3(self):
@@ -69,7 +71,8 @@ class NullBooleanFieldTest(FormFieldAssertionsMixin, SimpleTestCase):
self.assertTrue(f.has_changed(True, False))
self.assertTrue(f.has_changed(True, None))
self.assertTrue(f.has_changed(True, False))
- # HiddenInput widget sends string values for boolean but doesn't clean them in value_from_datadict
+ # HiddenInput widget sends string values for boolean but doesn't clean
+ # them in value_from_datadict.
self.assertFalse(f.has_changed(False, "False"))
self.assertFalse(f.has_changed(True, "True"))
self.assertFalse(f.has_changed(None, ""))
diff --git a/tests/forms_tests/field_tests/test_urlfield.py b/tests/forms_tests/field_tests/test_urlfield.py
index f74c6567c1..e0afd4a7e7 100644
--- a/tests/forms_tests/field_tests/test_urlfield.py
+++ b/tests/forms_tests/field_tests/test_urlfield.py
@@ -99,7 +99,8 @@ class URLFieldTest(FormFieldAssertionsMixin, SimpleTestCase):
f = URLField(min_length=15, max_length=20)
self.assertWidgetRendersTo(
f,
- '',
+ '",
)
with self.assertRaisesMessage(
ValidationError,
diff --git a/tests/forms_tests/models.py b/tests/forms_tests/models.py
index ae212f332d..d6d0725b32 100644
--- a/tests/forms_tests/models.py
+++ b/tests/forms_tests/models.py
@@ -56,8 +56,11 @@ class ChoiceModel(models.Model):
class ChoiceOptionModel(models.Model):
- """Destination for ChoiceFieldModel's ForeignKey.
- Can't reuse ChoiceModel because error_message tests require that it have no instances."""
+ """
+ Destination for ChoiceFieldModel's ForeignKey.
+ Can't reuse ChoiceModel because error_message tests require that it have no
+ instances.
+ """
name = models.CharField(max_length=10)
diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py
index d5833b972e..233a3a622d 100644
--- a/tests/forms_tests/tests/test_forms.py
+++ b/tests/forms_tests/tests/test_forms.py
@@ -100,18 +100,24 @@ class FormsTestCase(SimpleTestCase):
self.assertEqual(p.cleaned_data["birthday"], datetime.date(1940, 10, 9))
self.assertHTMLEqual(
str(p["first_name"]),
- '',
+ '",
)
self.assertHTMLEqual(
str(p["last_name"]),
- '',
+ '",
)
self.assertHTMLEqual(
str(p["birthday"]),
- '',
+ '",
)
- msg = "Key 'nonexistentfield' not found in 'Person'. Choices are: birthday, first_name, last_name."
+ msg = (
+ "Key 'nonexistentfield' not found in 'Person'. Choices are: birthday, "
+ "first_name, last_name."
+ )
with self.assertRaisesMessage(KeyError, msg):
p["nonexistentfield"]
@@ -142,12 +148,17 @@ class FormsTestCase(SimpleTestCase):
)
self.assertHTMLEqual(
str(p),
- """
-
+
-
-
-
-
-
- """,
+ """
+
-
+
+
+
+
+ """,
)
def test_empty_dict(self):
@@ -275,33 +286,41 @@ class FormsTestCase(SimpleTestCase):
self.assertHTMLEqual(
p.as_table(),
'
+ \n'
+ '\n"
''
- ' \n'
''
' ',
+ '",
)
self.assertHTMLEqual(
p.as_ul(),
''
- '
' '
\n' + 'value="\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111" ' + 'id="id_last_name" required>\n' '' - '
', + '", ) p = Person({"last_name": "Lennon"}) @@ -356,11 +375,11 @@ class FormsTestCase(SimpleTestCase): self.assertEqual(p.cleaned_data["birthday"], datetime.date(1940, 10, 9)) def test_optional_data(self): - # cleaned_data will include a key and value for *all* fields defined in the Form, - # even if the Form's data didn't include a value for fields that are not - # required. In this example, the data dictionary doesn't include a value for the - # "nick_name" field, but cleaned_data includes it. For CharFields, it's set to the - # empty string. + # cleaned_data will include a key and value for *all* fields defined in + # the Form, even if the Form's data didn't include a value for fields + # that are not required. In this example, the data dictionary doesn't + # include a value for the "nick_name" field, but cleaned_data includes + # it. For CharFields, it's set to the empty string. class OptionalPersonForm(Form): first_name = CharField() last_name = CharField() @@ -387,10 +406,10 @@ class FormsTestCase(SimpleTestCase): self.assertEqual(f.cleaned_data["last_name"], "Lennon") def test_auto_id(self): - # "auto_id" tells the Form to add an "id" attribute to each form element. - # If it's a string that contains '%s', Django will use that as a format string - # into which the field's name will be inserted. It will also put a self.assertTrue(f.is_valid()) self.assertHTMLEqual( str(f["when"]), - '' + '" '', ) self.assertHTMLEqual( @@ -1033,26 +1077,38 @@ Java f = SongForm(auto_id=False) self.assertHTMLEqual( str(f["composers"]), - """First name:
-Last name:
-Birthday:
""", + """ +First name:
+Last name:
+Birthday: +
+ """, ) # With auto_id set, a HiddenInput still gets an ID, but it doesn't get a label. @@ -1753,28 +1863,44 @@ value="Should escape < & > and <script>alert('xss')< ) self.assertHTMLEqual( p.as_table(), - """First name:
-Last name:
-Birthday: -
""", + """ +First name: +
+Last name: +
+Birthday: +
+ """, ) # A corner case: It's possible for a form to have only HiddenInputs. @@ -1816,20 +1942,11 @@ value="Should escape < & > and <script>alert('xss')< p = TestForm(auto_id=False) self.assertHTMLEqual( p.as_table(), - """