Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixed #20142 -- Added error handling for fixture setup #1127

Merged
merged 1 commit into from

2 participants

@filias

https://code.djangoproject.com/ticket/20142

This fix does not contain tests as it is impossible to test it without mocking and a decision about using mocks in the project as yet not been made. This was discussed and agreed with Russel.

@filias filias 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.
5883ae5
@aaugustin aaugustin merged commit 5915800 into django:master
@filias

test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 18, 2013
  1. @filias

    Fixed #20142 -- Added error handling for fixture setup

    filias authored
    TestCase._fixture_setup disables transactions so,
    in case of an error, cleanup is needed to re-enable
    transactions, otherwise following TransactionTestCase
    would fail.
This page is out of date. Refresh to see the latest.
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():
Something went wrong with that request. Please try again.