mirror of
https://github.com/django/django.git
synced 2025-09-26 12:09:19 +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
|
@ -115,16 +115,12 @@ class GenericRelationTests(TestCase):
|
|||
note.save()
|
||||
|
||||
def test_target_model_len_zero(self):
|
||||
"""Test for #13085 -- __len__() returns 0"""
|
||||
"""
|
||||
Saving a model with a GenericForeignKey to a model instance whose
|
||||
__len__ method returns 0 (Team.__len__() here) shouldn't fail (#13085).
|
||||
"""
|
||||
team1 = Team.objects.create(name='Backend devs')
|
||||
try:
|
||||
note = Note(note='Deserve a bonus', content_object=team1)
|
||||
except Exception as e:
|
||||
if (issubclass(type(e), Exception) and
|
||||
str(e) == 'Impossible arguments to GFK.get_content_type!'):
|
||||
self.fail("Saving model with GenericForeignKey to model instance whose "
|
||||
"__len__ method returns 0 shouldn't fail.")
|
||||
raise e
|
||||
note = Note(note='Deserve a bonus', content_object=team1)
|
||||
note.save()
|
||||
|
||||
def test_target_model_nonzero_false(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue