UPD: satisfy tests with django 3.2.8
Some checks failed
buildbot/tox Build done.

This commit is contained in:
2021-10-18 13:10:07 +02:00
parent c4e428f387
commit d0ee8e53d5
2 changed files with 27 additions and 6 deletions

View File

@@ -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

View File

@@ -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)