Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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.
  • Loading branch information...
commit 5883ae56b3e993052c46f7d9e756465b1387dd34 1 parent d5ce2ff
@filias filias authored
Showing with 11 additions and 7 deletions.
  1. +11 −7 django/test/testcases.py
View
18 django/test/testcases.py
@@ -843,13 +843,17 @@ def _fixture_setup(self):
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():
Please sign in to comment.
Something went wrong with that request. Please try again.