Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Filipa Andrade authored May 18, 2013

Showing 1 changed file with 11 additions and 7 deletions. Show diff stats Hide diff stats

  1. 18  django/test/testcases.py
18  django/test/testcases.py
@@ -843,13 +843,17 @@ def _fixture_setup(self):
843 843
 
844 844
         for db in self._databases_names(include_mirrors=False):
845 845
             if hasattr(self, 'fixtures'):
846  
-                call_command('loaddata', *self.fixtures,
847  
-                             **{
848  
-                                'verbosity': 0,
849  
-                                'commit': False,
850  
-                                'database': db,
851  
-                                'skip_validation': True,
852  
-                             })
  846
+                try:
  847
+                    call_command('loaddata', *self.fixtures,
  848
+                                 **{
  849
+                                    'verbosity': 0,
  850
+                                    'commit': False,
  851
+                                    'database': db,
  852
+                                    'skip_validation': True,
  853
+                                 })
  854
+                except Exception:
  855
+                    self._fixture_teardown()
  856
+                    raise
853 857
 
854 858
     def _fixture_teardown(self):
855 859
         if not connections_support_transactions():

0 notes on commit 5883ae5

Please sign in to comment.
Something went wrong with that request. Please try again.