Esempio n. 1
0
 def test_table_exists(self):
     try:
         cache.set_available_apps(settings.INSTALLED_APPS)
         call_command('migrate', verbosity=0)
     finally:
         cache.unset_available_apps()
     from .app1.models import ProxyModel
     from .app2.models import NiceModel
     self.assertEqual(NiceModel.objects.all().count(), 0)
     self.assertEqual(ProxyModel.objects.all().count(), 0)
Esempio n. 2
0
 def test_table_exists(self):
     try:
         cache.set_available_apps(settings.INSTALLED_APPS)
         call_command('migrate', verbosity=0)
     finally:
         cache.unset_available_apps()
     from .app1.models import ProxyModel
     from .app2.models import NiceModel
     self.assertEqual(NiceModel.objects.all().count(), 0)
     self.assertEqual(ProxyModel.objects.all().count(), 0)
Esempio n. 3
0
    def _pre_setup(self):
        """Performs any pre-test setup. This includes:

           * Flushing the database.
           * If the Test Case class has a 'fixtures' member, installing the
             named fixtures.
        """
        super(TransactionTestCase, self)._pre_setup()
        if self.available_apps is not None:
            cache.set_available_apps(self.available_apps)
        try:
            self._fixture_setup()
        except Exception:
            if self.available_apps is not None:
                cache.unset_available_apps()
            raise
Esempio n. 4
0
    def _pre_setup(self):
        """Performs any pre-test setup. This includes:

           * Flushing the database.
           * If the Test Case class has a 'fixtures' member, installing the
             named fixtures.
        """
        super(TransactionTestCase, self)._pre_setup()
        if self.available_apps is not None:
            cache.set_available_apps(self.available_apps)
        try:
            self._fixture_setup()
        except Exception:
            if self.available_apps is not None:
                cache.unset_available_apps()
            raise
Esempio n. 5
0
    def _pre_setup(self):
        """Performs any pre-test setup. This includes:

        * If the class has an 'available_apps' attribute, restricting the app
          cache to these applications, then firing post_migrate -- it must run
          with the correct set of applications for the test case.
        * If the class has a 'fixtures' attribute, installing these fixtures.
        """
        super(TransactionTestCase, self)._pre_setup()
        if self.available_apps is not None:
            cache.set_available_apps(self.available_apps)
            for db_name in self._databases_names(include_mirrors=False):
                flush.Command.emit_post_migrate(verbosity=0, interactive=False, database=db_name)
        try:
            self._fixture_setup()
        except Exception:
            if self.available_apps is not None:
                cache.unset_available_apps()
            raise
Esempio n. 6
0
    def _pre_setup(self):
        """Performs any pre-test setup. This includes:

        * If the class has an 'available_apps' attribute, restricting the app
          cache to these applications, then firing post_migrate -- it must run
          with the correct set of applications for the test case.
        * If the class has a 'fixtures' attribute, installing these fixtures.
        """
        super(TransactionTestCase, self)._pre_setup()
        if self.available_apps is not None:
            cache.set_available_apps(self.available_apps)
            for db_name in self._databases_names(include_mirrors=False):
                flush.Command.emit_post_migrate(verbosity=0, interactive=False, database=db_name)
        try:
            self._fixture_setup()
        except Exception:
            if self.available_apps is not None:
                cache.unset_available_apps()
            raise