Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit 11c1e61b99f40ed3e8d050fc88b624f52092b630 1 parent 735fbcf
@alex alex authored
Showing with 15 additions and 13 deletions.
  1. +15 −13 tests/regressiontests/fixtures_regress/tests.py
View
28 tests/regressiontests/fixtures_regress/tests.py
@@ -277,19 +277,21 @@ def test_field_value_coerce(self):
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):
"""
Please sign in to comment.
Something went wrong with that request. Please try again.