From 92053acbb9160862c3e743a99ed8ccff8d4f8fd6 Mon Sep 17 00:00:00 2001
From: Tim Graham
Date: Thu, 7 Apr 2016 22:04:45 -0400
Subject: Fixed E128 flake8 warnings in tests/.
---
tests/forms_tests/tests/test_fields.py | 16 +++++----
tests/forms_tests/tests/test_forms.py | 60 ++++++++++++++++++++------------
tests/forms_tests/tests/test_formsets.py | 9 +++--
tests/forms_tests/tests/test_utils.py | 29 ++++++++-------
tests/forms_tests/tests/test_widgets.py | 3 +-
5 files changed, 68 insertions(+), 49 deletions(-)
(limited to 'tests/forms_tests')
diff --git a/tests/forms_tests/tests/test_fields.py b/tests/forms_tests/tests/test_fields.py
index bd33cff4fd..41a3a5185e 100644
--- a/tests/forms_tests/tests/test_fields.py
+++ b/tests/forms_tests/tests/test_fields.py
@@ -850,8 +850,10 @@ class FieldsTests(SimpleTestCase):
self.assertEqual('person@example.com', f.clean('person@example.com'))
with self.assertRaisesMessage(ValidationError, "'Enter a valid email address.'"):
f.clean('foo')
- self.assertEqual('local@domain.with.idn.xyz\xe4\xf6\xfc\xdfabc.part.com',
- f.clean('local@domain.with.idn.xyzäöüßabc.part.com'))
+ self.assertEqual(
+ 'local@domain.with.idn.xyz\xe4\xf6\xfc\xdfabc.part.com',
+ f.clean('local@domain.with.idn.xyzäöüßabc.part.com')
+ )
def test_email_regexp_for_performance(self):
f = EmailField()
@@ -1259,9 +1261,11 @@ class FieldsTests(SimpleTestCase):
def test_choicefield_disabled(self):
f = ChoiceField(choices=[('J', 'John'), ('P', 'Paul')], disabled=True)
- self.assertWidgetRendersTo(f,
+ self.assertWidgetRendersTo(
+ f,
'')
+ ''
+ )
# TypedChoiceField ############################################################
# TypedChoiceField is just like ChoiceField, except that coerced types will
@@ -1434,8 +1438,8 @@ class FieldsTests(SimpleTestCase):
f.clean('hello')
self.assertEqual([], f.clean([]))
self.assertEqual([], f.clean(()))
- with self.assertRaisesMessage(ValidationError,
- "'Select a valid choice. 3 is not one of the available choices.'"):
+ msg = "'Select a valid choice. 3 is not one of the available choices.'"
+ with self.assertRaisesMessage(ValidationError, msg):
f.clean(['3'])
def test_multiplechoicefield_3(self):
diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py
index 99bcfe3417..a8bff32a8c 100644
--- a/tests/forms_tests/tests/test_forms.py
+++ b/tests/forms_tests/tests/test_forms.py
@@ -1493,11 +1493,13 @@ value="Should escape < & > and <script>alert('xss')</
address = CharField() # no max_length defined here
p = UserRegistration(auto_id=False)
- self.assertHTMLEqual(p.as_ul(),
- """
Username:
+ self.assertHTMLEqual(
+ p.as_ul(),
+ """
Username:
Password:
Realname:
-
Address:
""")
+
Address:
"""
+ )
# If you specify a custom "attrs" that includes the "maxlength" attribute,
# the Field's max_length attribute will override whatever "maxlength" you specify
@@ -1507,9 +1509,11 @@ value="Should escape < & > and <script>alert('xss')</
password = CharField(max_length=10, widget=PasswordInput)
p = UserRegistration(auto_id=False)
- self.assertHTMLEqual(p.as_ul(),
- """
Username:
-
Password:
""")
+ self.assertHTMLEqual(
+ p.as_ul(),
+ """
Username:
+
Password:
"""
+ )
def test_specifying_labels(self):
# You can specify the label for a field by using the 'label' argument to a Field
@@ -1521,10 +1525,12 @@ value="Should escape < & > and <script>alert('xss')</
password2 = CharField(widget=PasswordInput, label='Contraseña (de nuevo)')
p = UserRegistration(auto_id=False)
- self.assertHTMLEqual(p.as_ul(),
- """
Your username:
+ self.assertHTMLEqual(
+ p.as_ul(),
+ """
Your username:
Password1:
-
Contraseña (de nuevo):
""")
+
Contraseña (de nuevo):
"""
+ )
# Labels for as_* methods will only end in a colon if they don't end in other
# punctuation already.
@@ -1574,9 +1580,11 @@ value="Should escape < & > and <script>alert('xss')</
password = CharField(widget=PasswordInput)
p = UserRegistration(auto_id=False)
- self.assertHTMLEqual(p.as_ul(),
- """
'
+ )
# Can take a dict.
self.assertHTMLEqual(
str(ErrorList(sorted(ValidationError({'error_1': "1. Error one.", 'error_2': "2. Error two."}).messages))),
'
1. Error one.
2. Error two.
'
)
-
# Can take a mixture in a list.
self.assertHTMLEqual(
str(ErrorList(sorted(ValidationError([
diff --git a/tests/forms_tests/tests/test_widgets.py b/tests/forms_tests/tests/test_widgets.py
index 261cb4bc38..8f84ddcb9b 100644
--- a/tests/forms_tests/tests/test_widgets.py
+++ b/tests/forms_tests/tests/test_widgets.py
@@ -170,8 +170,7 @@ class LiveWidgetTests(AdminSeleniumTestCase):
Test that a roundtrip on a ModelForm doesn't alter the TextField value
"""
article = Article.objects.create(content="\nTst\n")
- self.selenium.get('%s%s' % (self.live_server_url,
- reverse('article_form', args=[article.pk])))
+ self.selenium.get(self.live_server_url + reverse('article_form', args=[article.pk]))
self.selenium.find_element_by_id('submit').submit()
article = Article.objects.get(pk=article.pk)
# Should be "\nTst\n" after #19251 is fixed
--
cgit v1.3