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 global pre_save_checks
pre_save_checks = [] pre_save_checks = []
signals.pre_save.connect(animal_pre_save_check) signals.pre_save.connect(animal_pre_save_check)
management.call_command( try:
'loaddata', management.call_command(
'animal.xml', 'loaddata',
verbosity=0, 'animal.xml',
commit=False, verbosity=0,
) commit=False,
self.assertEqual( )
pre_save_checks, self.assertEqual(
[ pre_save_checks,
("Count = 42 (<type 'int'>)", "Weight = 1.2 (<type 'float'>)") [
] ("Count = 42 (<type 'int'>)", "Weight = 1.2 (<type 'float'>)")
) ]
signals.pre_save.disconnect(animal_pre_save_check) )
finally:
signals.pre_save.disconnect(animal_pre_save_check)
def test_dumpdata_uses_default_manager(self): def test_dumpdata_uses_default_manager(self):
""" """