Commit 5883ae56 authored by Filipa Andrade's avatar Filipa Andrade
Browse files

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.
parent d5ce2ff5
Loading
Loading
Loading
Loading
+11 −7
Original line number Diff line number Diff line
@@ -843,6 +843,7 @@ class TestCase(TransactionTestCase):

        for db in self._databases_names(include_mirrors=False):
            if hasattr(self, 'fixtures'):
                try:
                    call_command('loaddata', *self.fixtures,
                                 **{
                                    'verbosity': 0,
@@ -850,6 +851,9 @@ class TestCase(TransactionTestCase):
                                    'database': db,
                                    'skip_validation': True,
                                 })
                except Exception:
                    self._fixture_teardown()
                    raise

    def _fixture_teardown(self):
        if not connections_support_transactions():