diff options
| author | Filipa Andrade <filipa.andrade@gmail.com> | 2013-05-18 17:04:52 +0200 |
|---|---|---|
| committer | Filipa Andrade <filipa.andrade@gmail.com> | 2013-05-18 17:05:45 +0200 |
| commit | 5883ae56b3e993052c46f7d9e756465b1387dd34 (patch) | |
| tree | 25312cad19492228e65ef26b7af3cfade3aaf2dd | |
| parent | d5ce2ff5e485bf94fcade340bc803ba4671bd95a (diff) | |
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.
| -rw-r--r-- | django/test/testcases.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/django/test/testcases.py b/django/test/testcases.py index 6fe6b9c397..6f8cbabd86 100644 --- a/django/test/testcases.py +++ b/django/test/testcases.py @@ -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(): |
