summaryrefslogtreecommitdiff
path: root/tests/validation
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2016-06-28 11:21:26 -0400
committerTim Graham <timograham@gmail.com>2016-07-01 09:58:56 -0400
commit567cfc1601a5f475eea12bc5de53b849fa5dadea (patch)
treec471ba1af748008e4fbe9faee8cf51d4dffcd263 /tests/validation
parent9c48e17480432b8723fcdcc262d8d62866e93a4f (diff)
[1.10.x] Replaced use of TestCase.fail() with assertRaises().
Also removed try/except/fail antipattern that hides exceptions. Backport of c9ae09addffb839403312131d4251e9d8b454508 from master
Diffstat (limited to 'tests/validation')
-rw-r--r--tests/validation/test_unique.py19
1 files changed, 7 insertions, 12 deletions
diff --git a/tests/validation/test_unique.py b/tests/validation/test_unique.py
index 8b79913d19..0780b9ec43 100644
--- a/tests/validation/test_unique.py
+++ b/tests/validation/test_unique.py
@@ -144,27 +144,22 @@ class PerformUniqueChecksTest(TestCase):
self.assertEqual(cm.exception.message_dict, {'posted': ['This field cannot be null.']})
def test_unique_for_date_with_nullable_date(self):
+ """
+ unique_for_date/year/month checks shouldn't trigger when the
+ associated DateField is None.
+ """
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()
- except ValidationError:
- self.fail("unique_for_date checks shouldn't trigger when the associated DateField is None.")
+ p.full_clean()
p = FlexibleDatePost(slug="Django 1.0")
- try:
- p.full_clean()
- except ValidationError:
- self.fail("unique_for_year checks shouldn't trigger when the associated DateField is None.")
+ p.full_clean()
p = FlexibleDatePost(subtitle="Finally")
- try:
- p.full_clean()
- except ValidationError:
- self.fail("unique_for_month checks shouldn't trigger when the associated DateField is None.")
+ p.full_clean()
def test_unique_errors(self):
UniqueErrorsModel.objects.create(name='Some Name', no=10)