Ticket #21089: ticket-21089.diff

File ticket-21089.diff, 2.2 KB (added by Baptiste Mispelon, 11 years ago)
  • django/test/testcases.py

    diff --git a/django/test/testcases.py b/django/test/testcases.py
    index b90fafa..5d265a5 100644
    a b class TransactionTestCase(SimpleTestCase):  
    699699    # Subclasses can enable only a subset of apps for faster tests
    700700    available_apps = None
    701701
     702    # Subclasses can define fixtures which will be automatically installed
     703    fixtures = None
     704
    702705    def _pre_setup(self):
    703706        """Performs any pre-test setup. This includes:
    704707
    class TransactionTestCase(SimpleTestCase):  
    746749            if self.reset_sequences:
    747750                self._reset_sequences(db_name)
    748751
    749             if hasattr(self, 'fixtures'):
    750                 # We have to use this slightly awkward syntax due to the fact
    751                 # that we're using *args and **kwargs together.
    752                 call_command('loaddata', *self.fixtures,
    753                              **{'verbosity': 0, 'database': db_name, 'skip_validation': True})
     752            if self.fixtures:
     753                call_command('loaddata', *self.fixtures, verbosity=0,
     754                             database=db_name, skip_validation=True)
    754755
    755756    def _post_teardown(self):
    756757        """Performs any post-test things. This includes:
    class TestCase(TransactionTestCase):  
    838839        disable_transaction_methods()
    839840
    840841        for db_name in self._databases_names(include_mirrors=False):
    841             if hasattr(self, 'fixtures'):
     842            if self.fixtures:
    842843                try:
    843844                    call_command('loaddata', *self.fixtures,
    844                                  **{
    845                                     'verbosity': 0,
    846                                     'commit': False,
    847                                     'database': db_name,
    848                                     'skip_validation': True,
    849                                  })
     845                                 verbosity=0,
     846                                 commit=False,
     847                                 database=db_name,
     848                                 skip_validation=True,
     849                    )
    850850                except Exception:
    851851                    self._fixture_teardown()
    852852                    raise
Back to Top