summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2011-09-26 10:11:18 +0000
committerAlex Gaynor <alex.gaynor@gmail.com>2011-09-26 10:11:18 +0000
commit11c1e61b99f40ed3e8d050fc88b624f52092b630 (patch)
tree6b45740e1334cdad2bdbc616c64f2feba4dc4d70 /tests
parent735fbcfe8b955591f2c1db860eafae3fb87d4f48 (diff)
Fixed #16925 -- Make sure a signal is disconnected if the test fails. Thanks to aaugustin for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16905 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/fixtures_regress/tests.py28
1 files changed, 15 insertions, 13 deletions
diff --git a/tests/regressiontests/fixtures_regress/tests.py b/tests/regressiontests/fixtures_regress/tests.py
index 575983ba81..b8e691490a 100644
--- a/tests/regressiontests/fixtures_regress/tests.py
+++ b/tests/regressiontests/fixtures_regress/tests.py
@@ -277,19 +277,21 @@ class TestFixtures(TestCase):
global pre_save_checks
pre_save_checks = []
signals.pre_save.connect(animal_pre_save_check)
- management.call_command(
- 'loaddata',
- 'animal.xml',
- verbosity=0,
- commit=False,
- )
- self.assertEqual(
- pre_save_checks,
- [
- ("Count = 42 (<type 'int'>)", "Weight = 1.2 (<type 'float'>)")
- ]
- )
- signals.pre_save.disconnect(animal_pre_save_check)
+ try:
+ management.call_command(
+ 'loaddata',
+ 'animal.xml',
+ verbosity=0,
+ commit=False,
+ )
+ self.assertEqual(
+ pre_save_checks,
+ [
+ ("Count = 42 (<type 'int'>)", "Weight = 1.2 (<type 'float'>)")
+ ]
+ )
+ finally:
+ signals.pre_save.disconnect(animal_pre_save_check)
def test_dumpdata_uses_default_manager(self):
"""