This commit is contained in:
@@ -11,6 +11,7 @@ disable=missing-docstring,
|
||||
missing-class-docstring,
|
||||
missing-function-docstring,
|
||||
useless-object-inheritance,
|
||||
consider-using-f-string,
|
||||
|
||||
[BASIC]
|
||||
|
||||
@@ -26,3 +27,7 @@ good-names=_,
|
||||
[FORMAT]
|
||||
|
||||
max-line-length=120
|
||||
|
||||
[SIMILARITIES]
|
||||
|
||||
ignore-comments=no
|
||||
|
||||
@@ -6,6 +6,8 @@ import unittest
|
||||
import mock
|
||||
import pytest
|
||||
|
||||
from django.utils.version import get_version
|
||||
|
||||
from ..config import DJANGO_SETTINGS_DIR
|
||||
|
||||
|
||||
@@ -155,15 +157,29 @@ class DjangoDeployTestCase(unittest.TestCase):
|
||||
self.fail('Unknown urlpattern class: {}'.format(real_class_name))
|
||||
|
||||
def assert_django_database_migration(self, project_dir, app_label=None, migration=None):
|
||||
version = get_version()
|
||||
major_version, _, _ = version.split('.')
|
||||
|
||||
management_script = os.path.join(project_dir, 'manage.py')
|
||||
cmd = [
|
||||
management_script, 'migrate', '--no-color', '--noinput'
|
||||
]
|
||||
|
||||
if int(major_version) <= 2:
|
||||
cmd = [
|
||||
management_script, 'migrate', '--no-color', '--noinput'
|
||||
]
|
||||
else:
|
||||
cmd = [
|
||||
management_script, 'migrate', '--no-color', '--noinput', '--check'
|
||||
]
|
||||
|
||||
if app_label is not None:
|
||||
cmd.append(app_label)
|
||||
if migration is not None:
|
||||
cmd.append(migration)
|
||||
|
||||
output = subprocess.check_output(cmd)
|
||||
text = output.decode('utf8')
|
||||
self.assertTrue(text.endswith('No migrations to apply.\n'))
|
||||
if int(major_version) <= 2:
|
||||
output = subprocess.check_output(cmd)
|
||||
text = output.decode('utf8')
|
||||
self.assertTrue(text.endswith('No migrations to apply.\n'))
|
||||
else:
|
||||
ret = subprocess.run(cmd, check=False)
|
||||
self.assertEqual(ret.returncode, 0)
|
||||
|
||||
Reference in New Issue
Block a user