diff options
| author | Tim Graham <timograham@gmail.com> | 2016-06-28 11:21:26 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-06-28 11:21:26 -0400 |
| commit | c9ae09addffb839403312131d4251e9d8b454508 (patch) | |
| tree | 74913fbe2e90d88e094f8594947ebf313ec5f12f /tests/generic_relations_regress | |
| parent | c1b6f554e405fe733e8d80f7e3d77c277810e707 (diff) | |
Replaced use of TestCase.fail() with assertRaises().
Also removed try/except/fail antipattern that hides exceptions.
Diffstat (limited to 'tests/generic_relations_regress')
| -rw-r--r-- | tests/generic_relations_regress/tests.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/tests/generic_relations_regress/tests.py b/tests/generic_relations_regress/tests.py index 0a5758d0fc..2c5b13dd23 100644 --- a/tests/generic_relations_regress/tests.py +++ b/tests/generic_relations_regress/tests.py @@ -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): |
