From 7cff1537a1a376c27529c099d6d0ac44cc59157e Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Thu, 23 Apr 2020 01:34:33 +0200 Subject: [PATCH] Enable django 3.0 (#361) --- .travis.yml | 8 +++ HISTORY.rst | 5 ++ README.rst | 14 ++--- djangocms_installer/config/__init__.py | 1 + djangocms_installer/config/data.py | 72 +++++++++++++++---------- djangocms_installer/install/__init__.py | 2 +- djangocms_installer/utils.py | 2 +- tests/base.py | 32 ++++++++--- tests/config.py | 35 ++++++------ tests/django.py | 68 ++++++++++++++++++----- tests/main.py | 32 +++++------ tox.ini | 2 +- 12 files changed, 183 insertions(+), 90 deletions(-) diff --git a/.travis.yml b/.travis.yml index 87e06e7..40f3b65 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ language: python dist: xenial python: + - 3.8 - 3.7 - 3.6 - 3.5 @@ -32,6 +33,7 @@ install: - "if [[ $TRAVIS_PYTHON_VERSION == '3.5' ]]; then export TOX_ENV=py35; fi" - "if [[ $TRAVIS_PYTHON_VERSION == '3.6' ]]; then export TOX_ENV=py36; fi" - "if [[ $TRAVIS_PYTHON_VERSION == '3.7' ]]; then export TOX_ENV=py37; fi" + - "if [[ $TRAVIS_PYTHON_VERSION == '3.8' ]]; then export TOX_ENV=py38; fi" - "if [[ $TEST != '1' ]]; then export TOX_ENV=$TEST; fi" # command to run tests, e.g. python setup.py test @@ -61,6 +63,12 @@ matrix: env: TEST='isort' - python: 3.6 env: TEST='docs' + - python: 3.7 + env: TEST='pep8' + - python: 3.7 + env: TEST='isort' + - python: 3.7 + env: TEST='docs' notifications: webhooks: https://ring.nephila.it/packages/hook/ diff --git a/HISTORY.rst b/HISTORY.rst index 0a38d44..53b9659 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -8,6 +8,11 @@ unreleased * Nothing yet +1.2.2 (unreleased) +++++++++++++++++++ + +* Added support for Django 3.0 + 1.2.1 (2019-12-27) ++++++++++++++++++ diff --git a/README.rst b/README.rst index 7646e95..8c4e033 100644 --- a/README.rst +++ b/README.rst @@ -88,13 +88,13 @@ Supported versions The current supported version matrix is the following: -+----------------+-------------+-------------+---------------+--------------+ -| | Django 1.11 | Django 2.0 | Django 2.1 | Django 2.2 | -+----------------+-------------+-------------+---------------+--------------+ -| django CMS 3.6 | Supported | Supported | Supported | Supported | -+----------------+-------------+-------------+---------------+--------------+ -| django CMS 3.7 | Supported | Supported | Supported | Supported | -+----------------+-------------+-------------+---------------+--------------+ ++----------------+-------------+-------------+---------------+--------------+--------------+ +| | Django 1.11 | Django 2.0 | Django 2.1 | Django 2.2 | Django 3.0 | ++----------------+-------------+-------------+---------------+--------------+--------------+ +| django CMS 3.6 | Supported | Supported | Supported | Supported | Supported | ++----------------+-------------+-------------+---------------+--------------+--------------+ +| django CMS 3.7 | Supported | Supported | Supported | Supported | Supported | ++----------------+-------------+-------------+---------------+--------------+--------------+ See `version 1.1`_ for older Django / django CMS versions support diff --git a/djangocms_installer/config/__init__.py b/djangocms_installer/config/__init__.py index f9ee486..9217894 100644 --- a/djangocms_installer/config/__init__.py +++ b/djangocms_installer/config/__init__.py @@ -232,6 +232,7 @@ def parse(args): except RuntimeError as e: # pragma: no cover sys.stderr.write(compat.unicode(e)) sys.exit(6) + if django_version is None: # pragma: no cover sys.stderr.write( 'Please provide a Django supported version: {0}. Only Major.Minor ' diff --git a/djangocms_installer/config/data.py b/djangocms_installer/config/data.py index 9da9541..5ad4c18 100644 --- a/djangocms_installer/config/data.py +++ b/djangocms_installer/config/data.py @@ -11,7 +11,7 @@ '--permissions', '--bootstrap', '--templates', '--starting-page'] -DJANGOCMS_DEVELOP = 'https://github.com/divio/django-cms/archive/develop.zip?{bust}'.format( +DJANGOCMS_DEVELOP = 'https://github.com/yakky/django-cms/archive/develop.zip?{bust}'.format( **bust ) DJANGOCMS_RC = 'https://github.com/divio/django-cms/archive/release/3.7.x.zip?{bust}'.format( @@ -19,7 +19,11 @@ ) DJANGOCMS_BETA = DJANGOCMS_RC DJANGOCMS_36 = 'django-cms>=3.6,<3.7' -DJANGOCMS_37 = 'django-cms>=3.7,<3.8' + +if sys.version_info > (3, 0): + DJANGOCMS_37 = 'django-cms>=3.7,<3.8' +else: + DJANGOCMS_37 = 'django-cms>=3.7,<3.7.2' if sys.version_info >= (3, 5): DJANGOCMS_SUPPORTED = ('3.6', '3.7', 'stable', 'lts', 'develop', 'rc') @@ -33,7 +37,11 @@ DJANGO_DEVELOP = 'https://github.com/django/django/archive/master.zip?{bust}'.format(**bust) DJANGO_BETA = 'https://github.com/django/django/archive/master.zip?{bust}'.format(**bust) -if sys.version_info >= (3, 5): +if sys.version_info >= (3, 6): + DJANGO_SUPPORTED = ('1.11', '2.0', '2.1', '2.2', '3.0', 'stable', 'lts') + DJANGO_STABLE = '3.0' + DJANGO_LTS = '2.2' +elif (3, 6) > sys.version_info >= (3, 5): DJANGO_SUPPORTED = ('1.11', '2.0', '2.1', '2.2', 'stable', 'lts') DJANGO_STABLE = '2.2' DJANGO_LTS = '2.2' @@ -53,16 +61,16 @@ DJANGO_VERSION_MATRIX = { 'stable': DJANGO_STABLE, 'lts': DJANGO_LTS, - 'rc': '2.2', - 'beta': '2.2', - 'develop': '2.2' + 'rc': DJANGO_STABLE, + 'beta': DJANGO_STABLE, + 'develop': DJANGO_STABLE } VERSION_MATRIX = { '3.6': ('1.11', '2.1'), - '3.7': ('1.11', '2.2'), - DJANGOCMS_BETA: ('1.11', '2.2'), - DJANGOCMS_RC: ('1.11', '2.2'), - DJANGOCMS_DEVELOP: ('1.11', '2.2'), + '3.7': ('1.11', '3.0'), + DJANGOCMS_BETA: ('1.11', '3.0'), + DJANGOCMS_RC: ('1.11', '3.0'), + DJANGOCMS_DEVELOP: ('1.11', '2.2', '3.0'), } PACKAGE_MATRIX = { '3.6': DJANGOCMS_36, @@ -100,6 +108,11 @@ 'django-sekizai>=1.0', 'django-mptt>0.9', ], + 'django-3.0': [ + 'django-classy-tags>=0.9', + 'django-sekizai>=1.0', + 'django-mptt>0.9', + ], 'reversion-django-1.11': [ 'django-reversion>=2.0,<2.1', ], @@ -116,32 +129,35 @@ 'django-treebeard>=4.0,<5.0', ], 'plugins-3.6': [ - 'djangocms-text-ckeditor>=3.7,<3.9', - 'djangocms-link>=2.3,<2.6', - 'djangocms-style>=2.2,<2.3', - 'djangocms-googlemap>=1.3,<1.4', - 'djangocms-snippet>=2.1,<2.3', - 'djangocms-video>=2.1,<2.3', - 'djangocms-file>=2.2,<3.0', - 'djangocms-picture>=2.3,<2.4', - 'djangocms-bootstrap4>=1.5,<1.6', + 'djangocms-text-ckeditor>=3.7,<4.0', + 'djangocms-link>=2.5,<2.7', + 'djangocms-icon>=1.4,<1.6', + 'djangocms-style>=2.2,<2.4', + 'djangocms-googlemap>=1.3,<1.5', + 'djangocms-snippet>=2.2,<2.4', + 'djangocms-video>=2.1,<2.4', + 'djangocms-file>=2.3,<2.5', + 'djangocms-picture>=2.3,<2.5', + 'djangocms-bootstrap4>=1.5,<1.7', ], 'plugins-3.7': [ - 'djangocms-text-ckeditor>=3.7,<3.9', - 'djangocms-link>=2.5,<2.6', - 'djangocms-style>=2.2,<2.3', - 'djangocms-googlemap>=1.3,<1.4', - 'djangocms-snippet>=2.2,<2.3', - 'djangocms-video>=2.1,<2.3', - 'djangocms-file>=2.3,<3.0', - 'djangocms-picture>=2.3,<2.4', - 'djangocms-bootstrap4>=1.5,<1.6', + 'djangocms-text-ckeditor>=3.7,<4.0', + 'djangocms-link>=2.5,<2.7', + 'djangocms-icon>=1.4,<1.6', + 'djangocms-style>=2.2,<2.4', + 'djangocms-googlemap>=1.3,<1.5', + 'djangocms-snippet>=2.2,<2.4', + 'djangocms-video>=2.1,<2.4', + 'djangocms-file>=2.3,<2.5', + 'djangocms-picture>=2.3,<2.5', + 'djangocms-bootstrap4>=1.5,<1.7', ], 'plugins-master': [ 'https://github.com/divio/djangocms-text-ckeditor/archive/master.zip?{bust}' ''.format(**bust), 'https://github.com/divio/djangocms-file/archive/master.zip?{bust}'.format(**bust), 'https://github.com/divio/djangocms-link/archive/master.zip?{bust}'.format(**bust), + 'https://github.com/divio/djangocms-icon/archive/master.zip?{bust}'.format(**bust), 'https://github.com/divio/djangocms-style/archive/master.zip?{bust}'.format(**bust), 'https://github.com/divio/djangocms-googlemap/archive/master.zip?{bust}'.format(**bust), 'https://github.com/divio/djangocms-snippet/archive/master.zip?{bust}'.format(**bust), diff --git a/djangocms_installer/install/__init__.py b/djangocms_installer/install/__init__.py index 92088c1..073141a 100644 --- a/djangocms_installer/install/__init__.py +++ b/djangocms_installer/install/__init__.py @@ -80,7 +80,7 @@ def check_install(config_data): def requirements(req_file, pip_options='', is_file=False, verbose=False): - args = ['install'] + args = ['install', '--disable-pip-version-check'] if not verbose: args.append('-q') if pip_options: diff --git a/djangocms_installer/utils.py b/djangocms_installer/utils.py index 4a34094..f8508d3 100644 --- a/djangocms_installer/utils.py +++ b/djangocms_installer/utils.py @@ -76,7 +76,7 @@ def supported_versions(django, cms): cms_version and django_version and not (LooseVersion(VERSION_MATRIX[compat.unicode(cms_version)][0]) <= LooseVersion(compat.unicode(django_version)) <= - LooseVersion(VERSION_MATRIX[compat.unicode(cms_version)][1])) + LooseVersion(VERSION_MATRIX[compat.unicode(cms_version)][-1])) ): raise RuntimeError( 'Django and django CMS versions doesn\'t match: ' diff --git a/tests/base.py b/tests/base.py index 15f39fb..2600e5f 100644 --- a/tests/base.py +++ b/tests/base.py @@ -117,23 +117,41 @@ def setUp(self): def get_latest_django(latest_stable=False, latest_1_x=False): """ - Get latest django version compatible with all the supported django CMS versions. + Get latest django version compatible with all the supported django CMS and python versions. Takes into account arguments and python version. """ if latest_1_x: dj_ver = '1.11' match = 'Django<2.0' - elif sys.version_info < (3, 4) and not latest_stable: - dj_ver = '1.11' - match = 'Django<2.0' - elif sys.version_info < (3, 4) and latest_stable: + elif sys.version_info < (3, 4): dj_ver = '1.11' match = 'Django<2.0' elif sys.version_info < (3, 5): dj_ver = '2.0' match = 'Django<2.1' + elif sys.version_info < (3, 6): + dj_ver = '2.2' + match = 'Django<2.3' + else: + dj_ver = '3.0' + match = 'Django<3.1' + return dj_ver, match + + +def get_latest_djangocms(latest_1_x=False): + """ + Get latest django CMS version compatible with all the supported django and python versions. + + Takes into account arguments and python version. + """ + if latest_1_x: + dj_ver = '3.7' + match = 'django-cms<3.8' + elif sys.version_info < (3, 5): + dj_ver = '3.7' + match = 'django-cms<3.8' else: - dj_ver = '2.1' - match = 'Django<2.2' + dj_ver = '3.7' + match = 'django-cms<3.8' return dj_ver, match diff --git a/tests/config.py b/tests/config.py index c44f847..ff0dc26 100644 --- a/tests/config.py +++ b/tests/config.py @@ -20,6 +20,8 @@ from .base import BaseTestClass, get_latest_django, unittest +latest_stable_django, latest_stable_django_match = get_latest_django() + class TestConfig(BaseTestClass): @@ -32,7 +34,7 @@ def test_default_config(self): self.assertEqual(conf_data.project_name, 'example_prj') self.assertEqual(conf_data.cms_version, '3.7') - self.assertEqual(conf_data.django_version, '2.2') + self.assertEqual(conf_data.django_version, latest_stable_django) self.assertEqual(conf_data.i18n, 'yes') self.assertEqual(conf_data.reversion, 'yes') self.assertEqual(conf_data.permissions, 'no') @@ -401,11 +403,11 @@ def test_latest_version(self): @unittest.skipIf(sys.version_info[0] < 3, reason='django 2+ only supports python 3') def test_supported_versions(self): - self.assertEqual(supported_versions('stable', 'stable'), ('2.2', '3.7')) - self.assertEqual(supported_versions('stable', '3.1.10'), ('2.2', None)) - self.assertEqual(supported_versions('stable', 'rc'), ('2.2', DJANGOCMS_RC)) - self.assertEqual(supported_versions('stable', 'beta'), ('2.2', DJANGOCMS_BETA)) - self.assertEqual(supported_versions('stable', 'develop'), ('2.2', DJANGOCMS_DEVELOP)) + self.assertEqual(supported_versions('stable', 'stable'), (latest_stable_django, '3.7')) + self.assertEqual(supported_versions('stable', '3.1.10'), (latest_stable_django, None)) + self.assertEqual(supported_versions('stable', 'rc'), (latest_stable_django, DJANGOCMS_RC)) + self.assertEqual(supported_versions('stable', 'beta'), (latest_stable_django, DJANGOCMS_BETA)) + self.assertEqual(supported_versions('stable', 'develop'), (latest_stable_django, DJANGOCMS_DEVELOP)) self.assertEqual(supported_versions('lts', 'rc'), ('2.2', DJANGOCMS_RC)) self.assertEqual(supported_versions('lts', 'lts'), ('2.2', '3.7')) @@ -464,7 +466,7 @@ def test_requirements(self): self.assertTrue(conf_data.requirements.find(config.data.DJANGOCMS_37) > -1) self.assertTrue(conf_data.requirements.find('Django<2.0') > -1) self.assertFalse(conf_data.requirements.find('django-reversion') > -1) - self.assertTrue(conf_data.requirements.find('djangocms-text-ckeditor>=3.7,<3.9') > -1) + self.assertTrue(conf_data.requirements.find('djangocms-text-ckeditor>=3.7,<4.0') > -1) self.assertTrue(conf_data.requirements.find('djangocms-admin-style>=1.4') > -1) self.assertTrue(conf_data.requirements.find('django-filer') > -1) self.assertTrue(conf_data.requirements.find('cmsplugin-filer') == -1) @@ -483,11 +485,11 @@ def test_requirements(self): 'example_prj']) self.assertTrue(conf_data.requirements.find(config.data.DJANGOCMS_37) > -1) - self.assertTrue(conf_data.requirements.find('Django<2.3') > -1) + self.assertTrue(conf_data.requirements.find(latest_stable_django_match) > -1) self.assertFalse(conf_data.requirements.find('django-reversion') > -1) self.assertTrue(conf_data.requirements.find('cmsplugin-filer') == -1) self.assertTrue(conf_data.requirements.find('djangocms-admin-style') > -1) - self.assertTrue(conf_data.requirements.find('djangocms-text-ckeditor>=3.7,<3.9') > -1) + self.assertTrue(conf_data.requirements.find('djangocms-text-ckeditor>=3.7,<4.0') > -1) self.assertTrue(conf_data.requirements.find('djangocms-bootstrap4') > -1) self.assertTrue(conf_data.requirements.find('djangocms-file') > -1) self.assertTrue(conf_data.requirements.find('djangocms-flash') == -1) @@ -576,7 +578,7 @@ def test_requirements(self): 'example_prj']) self.assertTrue(conf_data.requirements.find(config.data.DJANGOCMS_DEVELOP) > -1) - self.assertTrue(conf_data.requirements.find('Django<2.3') > -1) + self.assertTrue(conf_data.requirements.find(latest_stable_django_match) > -1) self.assertFalse(conf_data.requirements.find('django-reversion') > -1) self.assertTrue(conf_data.requirements.find('https://github.com/divio/djangocms-link') > -1) self.assertTrue(conf_data.requirements.find('https://github.com/divio/djangocms-style') > -1) @@ -601,9 +603,9 @@ def test_requirements(self): 'example_prj']) self.assertTrue(conf_data.requirements.find(config.data.DJANGOCMS_37) > -1) - self.assertTrue(conf_data.requirements.find('Django<2.3') > -1) + self.assertTrue(conf_data.requirements.find(latest_stable_django_match) > -1) self.assertFalse(conf_data.requirements.find('django-reversion') > -1) - self.assertTrue(conf_data.requirements.find('djangocms-text-ckeditor>=3.7,<3.9') > -1) + self.assertTrue(conf_data.requirements.find('djangocms-text-ckeditor>=3.7') > -1) self.assertTrue(conf_data.requirements.find('djangocms-admin-style') > -1) self.assertTrue(conf_data.requirements.find('pytz') > -1) @@ -622,7 +624,7 @@ def test_requirements(self): self.assertTrue(conf_data.requirements.find(config.data.DJANGOCMS_37) > -1) self.assertTrue(conf_data.requirements.find('Django<2.3') > -1) self.assertFalse(conf_data.requirements.find('django-reversion') > -1) - self.assertTrue(conf_data.requirements.find('djangocms-text-ckeditor>=3.7,<3.9') > -1) + self.assertTrue(conf_data.requirements.find('djangocms-text-ckeditor>=3.7') > -1) self.assertTrue(conf_data.requirements.find('djangocms-admin-style') > -1) self.assertTrue(conf_data.requirements.find('pytz') > -1) @@ -736,8 +738,9 @@ def test_requirements(self): '-p'+self.project_dir, 'example_prj']) - self.assertTrue(conf_data.requirements.find(config.data.DJANGOCMS_37) > -1) - self.assertTrue(conf_data.requirements.find('Django<2.3') > -1) + self.assertTrue(conf_data.requirements.find(config.data.DJANGOCMS_37) + > -1) + self.assertTrue(conf_data.requirements.find(latest_stable_django_match) > -1) def test_bootstrap(self): """ @@ -987,7 +990,7 @@ def test_parse_config_file(self, *args): ('config-03.ini', None, ( ('cms_version', '3.7'), ('i18n', 'no'), - ('django_version', '2.2'), + ('django_version', latest_stable_django), )), ('config-04.ini', None, (('cms_version', '3.7'), ('use_timezone', 'no'))), ('config-05.ini', None, (('cms_version', '3.7'), ('timezone', 'Europe/London'))), diff --git a/tests/django.py b/tests/django.py index 838ccb2..2bd11c7 100644 --- a/tests/django.py +++ b/tests/django.py @@ -11,9 +11,7 @@ from djangocms_installer import config, django, install -from .base import IsolatedTestClass, get_latest_django, unittest - -cms_stable = '3.6' +from .base import IsolatedTestClass, get_latest_django, get_latest_djangocms, unittest class TestDjango(IsolatedTestClass): @@ -34,7 +32,7 @@ class TestDjango(IsolatedTestClass): def test_create_project(self): dj_version, dj_match = get_latest_django(latest_stable=True) config_data = config.parse(['--db=postgres://user:pwd@host/dbname', - '--cms-version=%s' % cms_stable, '--django=%s' % dj_version, + '--cms-version=develop', '--django=%s' % dj_version, '-q', '-p' + self.project_dir, 'example_prj']) install.requirements(config_data.requirements) django.create_project(config_data) @@ -43,7 +41,7 @@ def test_create_project(self): def test_django_admin_errors(self): dj_version, dj_match = get_latest_django(latest_stable=True) config_data = config.parse(['--db=postgres://user:pwd@host/dbname', - '--cms-version=%s' % cms_stable, '--django=%s' % dj_version, + '--cms-version=develop', '--django=%s' % dj_version, '-q', '-p' + self.project_dir, 'example_prj']) install.requirements(config_data.requirements) config_data.project_name = 'example.prj' @@ -56,6 +54,8 @@ def test_copy_data(self): Test correct file copying with different switches """ dj_version, dj_match = get_latest_django(latest_stable=True) + cms_stable, cms_match = get_latest_djangocms() + # Basic template config_data = config.parse(['--db=postgres://user:pwd@host/dbname', '--cms-version=%s' % cms_stable, '--django=%s' % dj_version, @@ -119,6 +119,7 @@ def test_copy_data(self): def test_patch_111_settings(self): dj_version, dj_match = get_latest_django(latest_stable=True, latest_1_x=True) + cms_stable, cms_match = get_latest_djangocms(latest_1_x=True) extra_path = os.path.join(os.path.dirname(__file__), 'data', 'extra_settings.py') config_data = config.parse(['--db=sqlite://localhost/test.db', @@ -263,8 +264,36 @@ def test_patch_django_111_develop(self): project.settings.MIDDLEWARE ) - @unittest.skipIf(sys.version_info[:2] not in ((3, 5), (3, 6), (3, 7),), - reason='django 2.1 only supports python 3.5, 3.6 and 3.7') + @unittest.skipIf(sys.version_info[:2] not in ((3, 6), (3, 7), (3, 8),), + reason='django 3.0 only supports python 3.6, 3.7 and 3.8') + def test_patch_django_30_develop(self): + extra_path = os.path.join(os.path.dirname(__file__), 'data', 'extra_settings.py') + params = [ + '--db=sqlite://localhost/test.db', '--lang=en', '--extra-settings=%s' % extra_path, + '--django-version=3.0', '-f', '--cms-version=develop', '--timezone=Europe/Moscow', + '-q', '-u', '-zno', '--i18n=no', '-p' + self.project_dir, + 'test_patch_django_30_develop' + ] + config_data = config.parse(params) + install.requirements(config_data.requirements) + django.create_project(config_data) + django.patch_settings(config_data) + django.copy_files(config_data) + # settings is importable even in non django environment + sys.path.append(config_data.project_directory) + + project = __import__(config_data.project_name, globals(), locals(), [str('settings')]) + + # checking for django options + self.assertTrue(project.settings.TEMPLATES) + self.assertFalse(getattr(project.settings, 'TEMPLATES_DIR', False)) + self.assertTrue( + config.get_settings().APPHOOK_RELOAD_MIDDLEWARE_CLASS in + project.settings.MIDDLEWARE + ) + + @unittest.skipIf(sys.version_info[:2] not in ((3, 5), (3, 6), (3, 7), (3, 8),), + reason='django 2.2 only supports python 3.5-3.8') def test_patch_django_22_rc(self): extra_path = os.path.join(os.path.dirname(__file__), 'data', 'extra_settings.py') params = [ @@ -291,8 +320,8 @@ def test_patch_django_22_rc(self): project.settings.MIDDLEWARE ) - @unittest.skipIf(sys.version_info[:2] not in ((3, 5), (3, 6), (3, 7),), - reason='django 2.1 only supports python 3.5, 3.6 and 3.7') + @unittest.skipIf(sys.version_info[:2] not in ((3, 5), (3, 6), (3, 7), (3, 8),), + reason='django 2.1 only supports python 3.5-3.8') def test_patch_django_21_develop(self): extra_path = os.path.join(os.path.dirname(__file__), 'data', 'extra_settings.py') params = [ @@ -319,8 +348,8 @@ def test_patch_django_21_develop(self): project.settings.MIDDLEWARE ) - @unittest.skipIf(sys.version_info[:2] not in ((3, 5), (3, 6), (3, 7),), - reason='django 2.0 only supports python 3.5, 3.6 and 3.7') + @unittest.skipIf(sys.version_info[:2] not in ((3, 5), (3, 6), (3, 7), (3, 8),), + reason='django 2.0 only supports python 3.5-3.8') def test_patch_django_20_develop(self): extra_path = os.path.join(os.path.dirname(__file__), 'data', 'extra_settings.py') params = [ @@ -348,10 +377,13 @@ def test_patch_django_20_develop(self): ) def test_patch_django_111_no_plugins(self): + dj_version, dj_match = get_latest_django(latest_1_x=True) + cms_stable, cms_match = get_latest_djangocms(latest_1_x=True) + extra_path = os.path.join(os.path.dirname(__file__), 'data', 'extra_settings.py') config_data = config.parse(['--db=sqlite://localhost/test.db', '--lang=en', '--extra-settings=%s' % extra_path, - '--django-version=1.11', '-f', '--no-plugins', + '--django-version=%s' % dj_version, '-f', '--no-plugins', '--cms-version=%s' % cms_stable, '--timezone=Europe/Moscow', '-q', '-u', '-zno', '--i18n=no', '-p' + self.project_dir, 'test_patch_django_111_no_plugins']) @@ -388,6 +420,7 @@ def test_patch_django_111_no_plugins(self): def test_patch(self): dj_version, dj_match = get_latest_django(latest_stable=True) + cms_stable, cms_match = get_latest_djangocms() config_data = config.parse(['--db=sqlite://localhost/test.db', '--lang=en', @@ -475,6 +508,7 @@ def test_patch(self): def test_database_setup_filer(self): dj_version, dj_match = get_latest_django(latest_stable=True) + cms_stable, cms_match = get_latest_djangocms() config_data = config.parse(['--db=sqlite://localhost/test.db', '--cms-version=%s' % cms_stable, @@ -519,6 +553,7 @@ def test_database_setup_filer(self): def test_starting_page(self): dj_version, dj_match = get_latest_django(latest_stable=True) + cms_stable, cms_match = get_latest_djangocms() config_data = config.parse(['--db=sqlite://localhost/test.db', '--cms-version=%s' % cms_stable, @@ -547,9 +582,12 @@ def test_starting_page(self): self.assertTrue('TextPlugin' in row) def test_force_django(self): + dj_version, dj_match = get_latest_django(latest_1_x=True) + cms_stable, cms_match = get_latest_djangocms(latest_1_x=True) + config_data = config.parse(['--db=sqlite://localhost/test.db', - '-q', '-u', '--django-version=1.11', - '--cms-version=3.6', '--starting-page=yes', + '-q', '-u', '--starting-page=yes', + '--cms-version=%s' % cms_stable, '--django=%s' % dj_version, '-p' + self.project_dir, 'cms_project']) install.requirements(config_data.requirements) install.requirements('django<1.9') @@ -568,6 +606,8 @@ class TestBaseDjango(unittest.TestCase): def test_build_settings(self): """Tests django.__init__._build_settings function.""" dj_version, dj_match = get_latest_django(latest_stable=True) + cms_stable, cms_match = get_latest_djangocms() + config_data = config.parse(['--db=postgres://user:pwd@host:5432/dbname', '--cms-version=%s' % cms_stable, '--django=%s' % dj_version, '-q', '-p .', 'example_prj']) diff --git a/tests/main.py b/tests/main.py index 22f2c61..280c2ab 100644 --- a/tests/main.py +++ b/tests/main.py @@ -15,6 +15,8 @@ from .base import IsolatedTestClass, get_latest_django, unittest +latest_stable_django, latest_stable_django_match = get_latest_django() + class TestMain(IsolatedTestClass): @@ -22,15 +24,12 @@ def test_requirements_invocation(self): with patch('sys.stdout', self.stdout): with patch('sys.stderr', self.stderr): sys.argv = ['main'] + ['--db=sqlite://localhost/test.db', - '-len', '--cms-version=rc', '-R', + '-len', '--cms-version=stable', '-R', '-q', '-u', '-p' + self.project_dir, 'example_prj'] main.execute() stdout = self.stdout.getvalue() - if sys.version_info < (3, 5,): - self.assertTrue(stdout.find('Django<2.0') > -1) - else: - self.assertTrue(stdout.find('Django<2.3') > -1) + self.assertTrue(stdout.find(latest_stable_django_match) > -1) self.assertFalse(stdout.find('django-reversion') > -1) self.assertTrue(stdout.find('djangocms-text-ckeditor') > -1) self.assertTrue(stdout.find('djangocms-admin-style') > -1) @@ -85,7 +84,7 @@ def test_main_invocation(self): with patch('sys.stdout', self.stdout): with patch('sys.stderr', self.stderr): sys.argv = ['main'] + ['--db=sqlite://localhost/test.db', - '-len', '--cms-version=rc', '--django=%s' % dj_version, + '-len', '--cms-version=stable', '--django=%s' % dj_version, '-q', '-u', '--verbose', 'example_prj'] main.execute() @@ -108,7 +107,7 @@ def test_base_invocation(self): os.chdir(base_dir) with patch('sys.stdout', self.stdout): with patch('sys.stderr', self.stderr): - sys.argv = ['main'] + ['--cms-version=rc', 'example_prj'] + sys.argv = ['main'] + ['--cms-version=stable', 'example_prj'] main.execute() self.assertTrue(os.path.exists(os.path.join(project_dir, 'static'))) self.assertTrue(os.path.exists(os.path.join(project_dir, 'requirements.txt'))) @@ -129,21 +128,24 @@ def test_two_langs_invocation(self): with patch('sys.stdout', self.stdout): with patch('sys.stderr', self.stderr): sys.argv = ['main'] + ['--db=sqlite://localhost/test.db', - '-len-GB', '-lfr-fr', '--cms-version=rc', + '-len-GB', '-lfr-fr', '--cms-version=stable', '--verbose', '--django=%s' % dj_version, '-q', '-u', '-p' + self.project_dir, 'example_prj'] - main.execute() - # Checking we successfully completed the whole process - self.assertTrue(('Get into "%s" directory and type "python manage.py runserver" to start your project' % self.project_dir) in self.stdout.getvalue()) + try: + main.execute() + # Checking we successfully completed the whole process + self.assertTrue(('Get into "%s" directory and type "python manage.py runserver" to start your project' % self.project_dir) in self.stdout.getvalue()) + except Exception as e: + print(e) @unittest.skipIf(sys.version_info < (3.5,), - reason='django 2.1 does not support python < 3.5') + reason='django 2.0+ does not support python < 3.5') def test_develop(self): with patch('sys.stdout', self.stdout): with patch('sys.stderr', self.stderr): sys.argv = ['main'] + ['--db=sqlite://localhost/test.db', - '-len', '--cms-version=develop', '--django=2.1', + '-len', '--cms-version=develop', '--django=2.2', '-q', '-u', '-p'+self.project_dir, 'example_prj'] main.execute() @@ -179,7 +181,7 @@ def test_i18n_urls(self): os.chdir(base_dir) with patch('sys.stdout', self.stdout): with patch('sys.stderr', self.stderr): - sys.argv = ['main'] + ['--i18n=yes', '--cms-version=rc', 'example_prj'] + sys.argv = ['main'] + ['--i18n=yes', '--cms-version=stable', 'example_prj'] main.execute() self.assertTrue( os.path.exists( @@ -202,7 +204,7 @@ def test_noi18n_urls(self): os.chdir(base_dir) with patch('sys.stdout', self.stdout): with patch('sys.stderr', self.stderr): - sys.argv = ['main'] + ['--i18n=no', '--cms-version=rc', 'example_prj'] + sys.argv = ['main'] + ['--i18n=no', '--cms-version=stable', 'example_prj'] main.execute() self.assertTrue( os.path.exists( diff --git a/tox.ini b/tox.ini index 4958400..11c1732 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] downloadcache = {toxworkdir}/cache -envlist = pep8,isort,docs,py{37,6,35,27} +envlist = pep8,isort,docs,py{38,37,36,35,27} passenv = LANG [testenv]