summaryrefslogtreecommitdiff
path: root/tests/fixtures_regress
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2016-06-28 11:21:26 -0400
committerGitHub <noreply@github.com>2016-06-28 11:21:26 -0400
commitc9ae09addffb839403312131d4251e9d8b454508 (patch)
tree74913fbe2e90d88e094f8594947ebf313ec5f12f /tests/fixtures_regress
parentc1b6f554e405fe733e8d80f7e3d77c277810e707 (diff)
downloaddjango-c9ae09addffb839403312131d4251e9d8b454508.tar.gz
Replaced use of TestCase.fail() with assertRaises().
Also removed try/except/fail antipattern that hides exceptions.
Diffstat (limited to 'tests/fixtures_regress')
-rw-r--r--tests/fixtures_regress/tests.py27
1 files changed, 6 insertions, 21 deletions
diff --git a/tests/fixtures_regress/tests.py b/tests/fixtures_regress/tests.py
index 51a3ef54c0..71fe10528d 100644
--- a/tests/fixtures_regress/tests.py
+++ b/tests/fixtures_regress/tests.py
@@ -11,7 +11,6 @@ import warnings
import django
from django.core import management, serializers
from django.core.exceptions import ImproperlyConfigured
-from django.core.management.base import CommandError
from django.core.serializers.base import DeserializationError
from django.db import IntegrityError, transaction
from django.db.models import signals
@@ -838,15 +837,9 @@ class M2MNaturalKeyFixtureTests(TestCase):
A, B, C, AtoB, BtoC, CtoA = (M2MComplexCircular1A, M2MComplexCircular1B,
M2MComplexCircular1C, M2MCircular1ThroughAB,
M2MCircular1ThroughBC, M2MCircular1ThroughCA)
- try:
- sorted_deps = serializers.sort_dependencies(
- [('fixtures_regress', [A, B, C, AtoB, BtoC, CtoA])]
- )
- except CommandError:
- self.fail("Serialization dependency solving algorithm isn't "
- "capable of handling circular M2M setups with "
- "intermediate models.")
-
+ sorted_deps = serializers.sort_dependencies(
+ [('fixtures_regress', [A, B, C, AtoB, BtoC, CtoA])]
+ )
# The dependency sorting should not result in an error, and the
# through model should have dependencies to the other models and as
# such come last in the list.
@@ -858,17 +851,9 @@ class M2MNaturalKeyFixtureTests(TestCase):
Circular M2M relations with explicit through models should be serializable
This test tests the circularity with explicit natural_key.dependencies
"""
- try:
- sorted_deps = serializers.sort_dependencies([
- ('fixtures_regress', [
- M2MComplexCircular2A,
- M2MComplexCircular2B,
- M2MCircular2ThroughAB])
- ])
- except CommandError:
- self.fail("Serialization dependency solving algorithm isn't "
- "capable of handling circular M2M setups with "
- "intermediate models plus natural key dependency hints.")
+ sorted_deps = serializers.sort_dependencies([
+ ('fixtures_regress', [M2MComplexCircular2A, M2MComplexCircular2B, M2MCircular2ThroughAB])
+ ])
self.assertEqual(sorted_deps[:2], [M2MComplexCircular2A, M2MComplexCircular2B])
self.assertEqual(sorted_deps[2:], [M2MCircular2ThroughAB])