def prepareTestRunner(self, runner): """ Before running tests, initialize database et al, so noone will complain """ # FIXME: this should be lazy for tests that do not need test # database at all from django.db import connection from django.conf import settings self.old_name = settings.DATABASE_NAME try: from django.db import connections except ImportError: connections = {DEFAULT_DB_ALIAS: connection} if not self.persist_test_database or test_database_exists(): #connection.creation.create_test_db(verbosity=False, autoclobber=True) self.old_config = self.setup_databases(verbosity=False, autoclobber=True) for db in connections: if 'south' in settings.INSTALLED_APPS and getattr( settings, 'DST_RUN_SOUTH_MIGRATIONS', True): call_command('migrate', database=db) if getattr(settings, "FLUSH_TEST_DATABASE_AFTER_INITIAL_SYNCDB", False): getattr(settings, "TEST_DATABASE_FLUSH_COMMAND", flush_database)(self, database=db) flush_cache() self.need_flush = False
def prepareTestRunner(self, runner): """ Before running tests, initialize database et al, so noone will complain """ # FIXME: this should be lazy for tests that do not need test # database at all from django.conf import settings self.old_name = settings.DATABASE_NAME connections = self._get_databases() if not self.persist_test_database or test_database_exists(): #connection.creation.create_test_db(verbosity=False, autoclobber=True) self.old_config = self.setup_databases(verbosity=False, autoclobber=True) for db in connections: if getattr(settings, "FLUSH_TEST_DATABASE_AFTER_INITIAL_SYNCDB", False): getattr(settings, "TEST_DATABASE_FLUSH_COMMAND", flush_database)(self, database=db) flush_cache() self.need_flush = False
def prepareTestRunner(self, runner): """ Before running tests, initialize database et al, so noone will complain """ # FIXME: this should be lazy for tests that do not need test # database at all from django.db import connection from django.conf import settings self.old_name = settings.DATABASE_NAME try: from django.db import connections except ImportError: connections = {DEFAULT_DB_ALIAS : connection} if not self.persist_test_database or test_database_exists(): #connection.creation.create_test_db(verbosity=False, autoclobber=True) self.old_config = self.setup_databases(verbosity=False, autoclobber=True) for db in connections: if 'south' in settings.INSTALLED_APPS and getattr(settings, 'DST_RUN_SOUTH_MIGRATIONS', True): call_command('migrate', database=db) if getattr(settings, "FLUSH_TEST_DATABASE_AFTER_INITIAL_SYNCDB", False): getattr(settings, "TEST_DATABASE_FLUSH_COMMAND", flush_database)(self, database=db) flush_cache() self.need_flush = False