1
0
mirror of https://github.com/django/django.git synced 2024-12-25 02:26:12 +00:00

Fixed #20142 -- Added error handling for fixture setup

TestCase._fixture_setup disables transactions so,
in case of an error, cleanup is needed to re-enable
transactions, otherwise following TransactionTestCase
would fail.
This commit is contained in:
Filipa Andrade 2013-05-18 17:04:52 +02:00
parent d5ce2ff5e4
commit 5883ae56b3

View File

@ -843,13 +843,17 @@ class TestCase(TransactionTestCase):
for db in self._databases_names(include_mirrors=False):
if hasattr(self, 'fixtures'):
call_command('loaddata', *self.fixtures,
**{
'verbosity': 0,
'commit': False,
'database': db,
'skip_validation': True,
})
try:
call_command('loaddata', *self.fixtures,
**{
'verbosity': 0,
'commit': False,
'database': db,
'skip_validation': True,
})
except Exception:
self._fixture_teardown()
raise
def _fixture_teardown(self):
if not connections_support_transactions():