mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Replaced use of TestCase.fail() with assertRaises().
Also removed try/except/fail antipattern that hides exceptions.
This commit is contained in:
parent
c1b6f554e4
commit
c9ae09addf
30 changed files with 205 additions and 447 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue