mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #21283 -- Added support for migrations if models is a package.
Thanks Markus Holtermann for the report.
This commit is contained in:
@@ -2,12 +2,15 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import copy
|
||||
import datetime
|
||||
import os
|
||||
|
||||
from django.utils import six
|
||||
from django.test import TestCase
|
||||
from django.db.migrations.writer import MigrationWriter
|
||||
from django.db import models, migrations
|
||||
from django.db.migrations.writer import MigrationWriter
|
||||
from django.db.models.loading import cache
|
||||
from django.test import TestCase, override_settings
|
||||
from django.utils import six
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
|
||||
@@ -95,3 +98,24 @@ class WriterTests(TestCase):
|
||||
# Just make sure it runs for now, and that things look alright.
|
||||
result = self.safe_exec(output)
|
||||
self.assertIn("Migration", result)
|
||||
|
||||
def test_migration_path(self):
|
||||
_old_app_store = copy.deepcopy(cache.app_store)
|
||||
|
||||
test_apps = [
|
||||
'migrations.migrations_test_apps.normal',
|
||||
'migrations.migrations_test_apps.with_package_model',
|
||||
]
|
||||
|
||||
base_dir = os.path.dirname(os.path.dirname(__file__))
|
||||
|
||||
try:
|
||||
with override_settings(INSTALLED_APPS=test_apps):
|
||||
for app in test_apps:
|
||||
cache.load_app(app)
|
||||
migration = migrations.Migration('0001_initial', app.split('.')[-1])
|
||||
expected_path = os.path.join(base_dir, *(app.split('.') + ['migrations', '0001_initial.py']))
|
||||
writer = MigrationWriter(migration)
|
||||
self.assertEqual(writer.path, expected_path)
|
||||
finally:
|
||||
cache.app_store = _old_app_store
|
||||
|
||||
Reference in New Issue
Block a user