Loading django/conf/global_settings.py +7 −0 Original line number Diff line number Diff line Loading @@ -602,3 +602,10 @@ STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.AppDirectoriesFinder', # 'django.contrib.staticfiles.finders.DefaultStorageFinder', ) ############## # MIGRATIONS # ############## # Migration module overrides for apps, by app label. MIGRATION_MODULES = {} django/db/backends/creation.py +4 −3 Original line number Diff line number Diff line Loading @@ -331,14 +331,15 @@ class BaseDatabaseCreation(object): settings.DATABASES[self.connection.alias]["NAME"] = test_database_name self.connection.settings_dict["NAME"] = test_database_name # Report syncdb messages at one level lower than that requested. # Report migrate messages at one level lower than that requested. # This ensures we don't get flooded with messages during testing # (unless you really ask to be flooded) call_command('syncdb', call_command('migrate', verbosity=max(verbosity - 1, 0), interactive=False, database=self.connection.alias, load_initial_data=False) load_initial_data=False, test_database=True) # We need to then do a flush to ensure that any data installed by # custom SQL has been removed. The only test data should come from Loading django/db/migrations/loader.py +9 −2 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ from django.utils.functional import cached_property from django.db.models.loading import cache from django.db.migrations.recorder import MigrationRecorder from django.db.migrations.graph import MigrationGraph from django.conf import settings class MigrationLoader(object): Loading Loading @@ -36,6 +37,12 @@ class MigrationLoader(object): self.disk_migrations = None self.applied_migrations = None def migration_module(self, app_label): if app_label in settings.MIGRATION_MODULES: return settings.MIGRATION_MODULES[app_label] app = cache.get_app(app_label) return ".".join(app.__name__.split(".")[:-1] + ["migrations"]) def load_disk(self): """ Loads the migrations from all INSTALLED_APPS from disk. Loading @@ -44,8 +51,8 @@ class MigrationLoader(object): self.unmigrated_apps = set() for app in cache.get_apps(): # Get the migrations module directory module_name = ".".join(app.__name__.split(".")[:-1] + ["migrations"]) app_label = module_name.split(".")[-2] app_label = app.__name__.split(".")[-2] module_name = self.migration_module(app_label) try: module = import_module(module_name) except ImportError as e: Loading tests/migrations/test_executor.py +4 −0 Original line number Diff line number Diff line from django.test import TransactionTestCase from django.test.utils import override_settings from django.db import connection from django.db.migrations.executor import MigrationExecutor Loading @@ -11,6 +12,9 @@ class ExecutorTests(TransactionTestCase): test failures first, as they may be propagating into here. """ available_apps = ["migrations"] @override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations"}) def test_run(self): """ Tests running a simple set of migrations. Loading tests/migrations/test_loader.py +4 −2 Original line number Diff line number Diff line from django.test import TestCase, TransactionTestCase from django.test import TestCase from django.test.utils import override_settings from django.db import connection from django.db.migrations.loader import MigrationLoader from django.db.migrations.recorder import MigrationRecorder Loading Loading @@ -30,12 +31,13 @@ class RecorderTests(TestCase): ) class LoaderTests(TransactionTestCase): class LoaderTests(TestCase): """ Tests the disk and database loader, and running through migrations in memory. """ @override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations"}) def test_load(self): """ Makes sure the loader can load the migrations for the test apps, Loading Loading
django/conf/global_settings.py +7 −0 Original line number Diff line number Diff line Loading @@ -602,3 +602,10 @@ STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.AppDirectoriesFinder', # 'django.contrib.staticfiles.finders.DefaultStorageFinder', ) ############## # MIGRATIONS # ############## # Migration module overrides for apps, by app label. MIGRATION_MODULES = {}
django/db/backends/creation.py +4 −3 Original line number Diff line number Diff line Loading @@ -331,14 +331,15 @@ class BaseDatabaseCreation(object): settings.DATABASES[self.connection.alias]["NAME"] = test_database_name self.connection.settings_dict["NAME"] = test_database_name # Report syncdb messages at one level lower than that requested. # Report migrate messages at one level lower than that requested. # This ensures we don't get flooded with messages during testing # (unless you really ask to be flooded) call_command('syncdb', call_command('migrate', verbosity=max(verbosity - 1, 0), interactive=False, database=self.connection.alias, load_initial_data=False) load_initial_data=False, test_database=True) # We need to then do a flush to ensure that any data installed by # custom SQL has been removed. The only test data should come from Loading
django/db/migrations/loader.py +9 −2 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ from django.utils.functional import cached_property from django.db.models.loading import cache from django.db.migrations.recorder import MigrationRecorder from django.db.migrations.graph import MigrationGraph from django.conf import settings class MigrationLoader(object): Loading Loading @@ -36,6 +37,12 @@ class MigrationLoader(object): self.disk_migrations = None self.applied_migrations = None def migration_module(self, app_label): if app_label in settings.MIGRATION_MODULES: return settings.MIGRATION_MODULES[app_label] app = cache.get_app(app_label) return ".".join(app.__name__.split(".")[:-1] + ["migrations"]) def load_disk(self): """ Loads the migrations from all INSTALLED_APPS from disk. Loading @@ -44,8 +51,8 @@ class MigrationLoader(object): self.unmigrated_apps = set() for app in cache.get_apps(): # Get the migrations module directory module_name = ".".join(app.__name__.split(".")[:-1] + ["migrations"]) app_label = module_name.split(".")[-2] app_label = app.__name__.split(".")[-2] module_name = self.migration_module(app_label) try: module = import_module(module_name) except ImportError as e: Loading
tests/migrations/test_executor.py +4 −0 Original line number Diff line number Diff line from django.test import TransactionTestCase from django.test.utils import override_settings from django.db import connection from django.db.migrations.executor import MigrationExecutor Loading @@ -11,6 +12,9 @@ class ExecutorTests(TransactionTestCase): test failures first, as they may be propagating into here. """ available_apps = ["migrations"] @override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations"}) def test_run(self): """ Tests running a simple set of migrations. Loading
tests/migrations/test_loader.py +4 −2 Original line number Diff line number Diff line from django.test import TestCase, TransactionTestCase from django.test import TestCase from django.test.utils import override_settings from django.db import connection from django.db.migrations.loader import MigrationLoader from django.db.migrations.recorder import MigrationRecorder Loading Loading @@ -30,12 +31,13 @@ class RecorderTests(TestCase): ) class LoaderTests(TransactionTestCase): class LoaderTests(TestCase): """ Tests the disk and database loader, and running through migrations in memory. """ @override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations"}) def test_load(self): """ Makes sure the loader can load the migrations for the test apps, Loading