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
This commit is contained in:
Alex Gaynor 2011-09-26 10:11:18 +00:00
parent 735fbcfe8b
commit 11c1e61b99
1 changed files with 15 additions and 13 deletions

View File

@ -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):
"""