summaryrefslogtreecommitdiff
path: root/tests/validation
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2016-04-07 22:04:45 -0400
committerTim Graham <timograham@gmail.com>2016-04-08 10:12:33 -0400
commit92053acbb9160862c3e743a99ed8ccff8d4f8fd6 (patch)
tree50e7fd28a650f0e2352cf94f92e5a66d28a81988 /tests/validation
parentdf8d8d4292684d6ffa7474f1e201aed486f02b53 (diff)
Fixed E128 flake8 warnings in tests/.
Diffstat (limited to 'tests/validation')
-rw-r--r--tests/validation/models.py6
-rw-r--r--tests/validation/test_error_messages.py89
-rw-r--r--tests/validation/test_unique.py20
-rw-r--r--tests/validation/tests.py13
4 files changed, 64 insertions, 64 deletions
diff --git a/tests/validation/models.py b/tests/validation/models.py
index 6b3d670000..83b998c38f 100644
--- a/tests/validation/models.py
+++ b/tests/validation/models.py
@@ -68,7 +68,8 @@ class UniqueForDateModel(models.Model):
class CustomMessagesModel(models.Model):
other = models.IntegerField(blank=True, null=True)
- number = models.IntegerField(db_column='number_val',
+ number = models.IntegerField(
+ db_column='number_val',
error_messages={'null': 'NULL', 'not42': 'AAARGH', 'not_equal': '%s != me'},
validators=[validate_answer_to_universe]
)
@@ -115,8 +116,7 @@ class GenericIPAddressTestModel(models.Model):
generic_ip = models.GenericIPAddressField(blank=True, null=True, unique=True)
v4_ip = models.GenericIPAddressField(blank=True, null=True, protocol="ipv4")
v6_ip = models.GenericIPAddressField(blank=True, null=True, protocol="ipv6")
- ip_verbose_name = models.GenericIPAddressField("IP Address Verbose",
- blank=True, null=True)
+ ip_verbose_name = models.GenericIPAddressField("IP Address Verbose", blank=True, null=True)
class GenericIPAddrUnpackUniqueTest(models.Model):
diff --git a/tests/validation/test_error_messages.py b/tests/validation/test_error_messages.py
index 9b0bf701b1..c71b8cd60a 100644
--- a/tests/validation/test_error_messages.py
+++ b/tests/validation/test_error_messages.py
@@ -16,78 +16,75 @@ class ValidationMessagesTest(TestCase):
def test_autofield_field_raises_error_message(self):
f = models.AutoField(primary_key=True)
- self._test_validation_messages(f, 'fõo',
- ["'fõo' value must be an integer."])
+ self._test_validation_messages(f, 'fõo', ["'fõo' value must be an integer."])
def test_integer_field_raises_error_message(self):
f = models.IntegerField()
- self._test_validation_messages(f, 'fõo',
- ["'fõo' value must be an integer."])
+ self._test_validation_messages(f, 'fõo', ["'fõo' value must be an integer."])
def test_boolean_field_raises_error_message(self):
f = models.BooleanField()
- self._test_validation_messages(f, 'fõo',
- ["'fõo' value must be either True or False."])
+ self._test_validation_messages(f, 'fõo', ["'fõo' value must be either True or False."])
def test_float_field_raises_error_message(self):
f = models.FloatField()
- self._test_validation_messages(f, 'fõo',
- ["'fõo' value must be a float."])
+ self._test_validation_messages(f, 'fõo', ["'fõo' value must be a float."])
def test_decimal_field_raises_error_message(self):
f = models.DecimalField()
- self._test_validation_messages(f, 'fõo',
- ["'fõo' value must be a decimal number."])
+ self._test_validation_messages(f, 'fõo', ["'fõo' value must be a decimal number."])
def test_null_boolean_field_raises_error_message(self):
f = models.NullBooleanField()
- self._test_validation_messages(f, 'fõo',
- ["'fõo' value must be either None, True or False."])
+ self._test_validation_messages(f, 'fõo', ["'fõo' value must be either None, True or False."])
def test_date_field_raises_error_message(self):
f = models.DateField()
- self._test_validation_messages(f, 'fõo',
- ["'fõo' value has an invalid date format. "
- "It must be in YYYY-MM-DD format."])
-
- self._test_validation_messages(f, 'aaaa-10-10',
- ["'aaaa-10-10' value has an invalid date format. "
- "It must be in YYYY-MM-DD format."])
-
- self._test_validation_messages(f, '2011-13-10',
- ["'2011-13-10' value has the correct format (YYYY-MM-DD) "
- "but it is an invalid date."])
-
- self._test_validation_messages(f, '2011-10-32',
- ["'2011-10-32' value has the correct format (YYYY-MM-DD) "
- "but it is an invalid date."])
+ self._test_validation_messages(
+ f, 'fõo',
+ ["'fõo' value has an invalid date format. It must be in YYYY-MM-DD format."]
+ )
+ self._test_validation_messages(
+ f, 'aaaa-10-10',
+ ["'aaaa-10-10' value has an invalid date format. It must be in YYYY-MM-DD format."]
+ )
+ self._test_validation_messages(
+ f, '2011-13-10',
+ ["'2011-13-10' value has the correct format (YYYY-MM-DD) but it is an invalid date."]
+ )
+ self._test_validation_messages(
+ f, '2011-10-32',
+ ["'2011-10-32' value has the correct format (YYYY-MM-DD) but it is an invalid date."]
+ )
def test_datetime_field_raises_error_message(self):
f = models.DateTimeField()
# Wrong format
- self._test_validation_messages(f, 'fõo',
- ["'fõo' value has an invalid format. It must be "
- "in YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ] format."])
-
+ self._test_validation_messages(
+ f, 'fõo',
+ ["'fõo' value has an invalid format. It must be in YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ] format."]
+ )
# Correct format but invalid date
- self._test_validation_messages(f, '2011-10-32',
- ["'2011-10-32' value has the correct format "
- "(YYYY-MM-DD) but it is an invalid date."])
-
+ self._test_validation_messages(
+ f, '2011-10-32',
+ ["'2011-10-32' value has the correct format (YYYY-MM-DD) but it is an invalid date."]
+ )
# Correct format but invalid date/time
- self._test_validation_messages(f, '2011-10-32 10:10',
- ["'2011-10-32 10:10' value has the correct format "
- "(YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ]) "
- "but it is an invalid date/time."])
+ self._test_validation_messages(
+ f, '2011-10-32 10:10',
+ ["'2011-10-32 10:10' value has the correct format (YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ]) "
+ "but it is an invalid date/time."]
+ )
def test_time_field_raises_error_message(self):
f = models.TimeField()
# Wrong format
- self._test_validation_messages(f, 'fõo',
- ["'fõo' value has an invalid format. It must be in "
- "HH:MM[:ss[.uuuuuu]] format."])
-
+ self._test_validation_messages(
+ f, 'fõo',
+ ["'fõo' value has an invalid format. It must be in HH:MM[:ss[.uuuuuu]] format."]
+ )
# Correct format but invalid time
- self._test_validation_messages(f, '25:50',
- ["'25:50' value has the correct format "
- "(HH:MM[:ss[.uuuuuu]]) but it is an invalid time."])
+ self._test_validation_messages(
+ f, '25:50',
+ ["'25:50' value has the correct format (HH:MM[:ss[.uuuuuu]]) but it is an invalid time."]
+ )
diff --git a/tests/validation/test_unique.py b/tests/validation/test_unique.py
index 2abe85c82c..8b79913d19 100644
--- a/tests/validation/test_unique.py
+++ b/tests/validation/test_unique.py
@@ -41,10 +41,8 @@ class GetUniqueCheckTests(unittest.TestCase):
objects.
"""
data = {
- '2-tuple': (('foo', 'bar'),
- (('foo', 'bar'),)),
- 'list': (['foo', 'bar'],
- (('foo', 'bar'),)),
+ '2-tuple': (('foo', 'bar'), (('foo', 'bar'),)),
+ 'list': (['foo', 'bar'], (('foo', 'bar'),)),
'already normalized': ((('foo', 'bar'), ('bar', 'baz')),
(('foo', 'bar'), ('bar', 'baz'))),
'set': ({('foo', 'bar'), ('bar', 'baz')}, # Ref #21469
@@ -113,9 +111,10 @@ class PerformUniqueChecksTest(TestCase):
mtv.full_clean()
def test_unique_for_date(self):
- Post.objects.create(title="Django 1.0 is released",
- slug="Django 1.0", subtitle="Finally", posted=datetime.date(2008, 9, 3))
-
+ Post.objects.create(
+ title="Django 1.0 is released", slug="Django 1.0",
+ subtitle="Finally", posted=datetime.date(2008, 9, 3),
+ )
p = Post(title="Django 1.0 is released", posted=datetime.date(2008, 9, 3))
with self.assertRaises(ValidationError) as cm:
p.full_clean()
@@ -145,9 +144,10 @@ class PerformUniqueChecksTest(TestCase):
self.assertEqual(cm.exception.message_dict, {'posted': ['This field cannot be null.']})
def test_unique_for_date_with_nullable_date(self):
- FlexibleDatePost.objects.create(title="Django 1.0 is released",
- slug="Django 1.0", subtitle="Finally", posted=datetime.date(2008, 9, 3))
-
+ FlexibleDatePost.objects.create(
+ title="Django 1.0 is released", slug="Django 1.0",
+ subtitle="Finally", posted=datetime.date(2008, 9, 3),
+ )
p = FlexibleDatePost(title="Django 1.0 is released")
try:
p.full_clean()
diff --git a/tests/validation/tests.py b/tests/validation/tests.py
index 653a6b1c4c..af8f195194 100644
--- a/tests/validation/tests.py
+++ b/tests/validation/tests.py
@@ -28,12 +28,15 @@ class BaseModelValidationTests(ValidationTestCase):
def test_wrong_FK_value_raises_error(self):
mtv = ModelToValidate(number=10, name='Some Name', parent_id=3)
- self.assertFieldFailsValidationWithMessage(mtv.full_clean, 'parent',
- ['model to validate instance with id %r does not exist.' % mtv.parent_id])
-
+ self.assertFieldFailsValidationWithMessage(
+ mtv.full_clean, 'parent',
+ ['model to validate instance with id %r does not exist.' % mtv.parent_id]
+ )
mtv = ModelToValidate(number=10, name='Some Name', ufm_id='Some Name')
- self.assertFieldFailsValidationWithMessage(mtv.full_clean, 'ufm',
- ["unique fields model instance with unique_charfield %r does not exist." % mtv.name])
+ self.assertFieldFailsValidationWithMessage(
+ mtv.full_clean, 'ufm',
+ ["unique fields model instance with unique_charfield %r does not exist." % mtv.name]
+ )
def test_correct_FK_value_validates(self):
parent = ModelToValidate.objects.create(number=10, name='Some Name')