Add unit tests with Django 4.2

Django 4.2 is our primary version in 2023.2 (Caracal),
so we need to start testing with Django 4.2.
Once all unit tests work, let's switch it to voting.

PYTHONWARNINGS in tox.ini is also simplified. We had three similar
variants of PYTHONWARNINGS in tox.ini. There is no need to use a
different value for py3 and py39 as we already use py39 by default.
PendingDeprecationWarning was added to hide Django deprecation
warnings, so I keep it now. On the other hand I think we should
handle Django deprecation warnings much earlier to sync Django
releases more promptly, so TODO comment is added.

Change-Id: I530be8fde637a912968b4ce7dbc94a4108dc50df
This commit is contained in:
Akihiro Motoki 2022-07-28 04:10:29 +09:00
parent 57c92f54b2
commit 40e416b8fc
2 changed files with 31 additions and 18 deletions

View File

@ -12,27 +12,45 @@
.. zuul:jobvar: django_version
Django version to be used.
pip version specifier like ``>=1.11,<2.0`` should be passed.
pip version specifier like ``>=4.2,<4.3`` should be passed.
pre-run: playbooks/horizon-tox-django/pre.yaml
run: playbooks/horizon-tox-django/run.yaml
vars:
tox_envlist: py39
tox_envlist: py311
# The following should match the base openstack-tox-pyNN job.
bindep_profile: test py311
python_version: "3.11"
required-projects:
- name: openstack/horizon
# Let's keep at least one job definition as a template even when we support
# only one version of Django covered by the default job.
- job:
name: horizon-tox-python3-django42
parent: horizon-tox-python3-django
vars:
django_version: '>=4.2,<4.3'
- project-template:
name: horizon-non-primary-django-jobs
description: |
Run unit tests with non-primary Django versions.
check:
jobs:
# Currently we only support Django 3.2, so there is no need
# to run tests with different versions of Django.
# We specify a job in openstack-python3-jobs(-horizon)
# to keep this project template as it is used in horizon plugins.
# NOTE: We keep it as a template even though it is not used now.
- openstack-tox-py39
# We specify a job in openstack-python3-jobs(-horizon) as a
# sentinel to make this project template valid even when we support
# only one version of Django used as the default. Zuul project
# template configuration requires at least one job included.
- openstack-tox-py311
# Let's keep at least one job as a template even when we support
# only one version of Django covered by the default job.
# Just comment it out for such case.
- horizon-tox-python3-django42:
voting: false
gate:
jobs:
- openstack-tox-py39
# Default python job in openstack-python3-antelope-jobs(-horizon)
- openstack-tox-py311
# Skip the following until they become voting.
# - horizon-tox-python3-django42

13
tox.ini
View File

@ -1,6 +1,6 @@
[tox]
minversion = 3.18.0
envlist = pep8,py39,releasenotes,npm,py3-dj32
envlist = pep8,py39,releasenotes,npm,py3-dj42
# Automatic envs (pyXX) will only use the python version appropriate to that
# env and ignore basepython inherited from [testenv] if we set
# ignore_basepython_conflict.
@ -12,14 +12,9 @@ usedevelop = True
setenv =
VIRTUAL_ENV = {envdir}
PYTHONDONTWRITEBYTECODE = 1
# TODO(amotoki): There are three variants of PYTHONWARNINGS. They should be merged.
# TODO(amotoki): Consider dropping PendingDeprecationWarning
# handle deprecated Django features earlier.
PYTHONWARNINGS = once,ignore::PendingDeprecationWarning
py{3,39}: PYTHONWARNINGS = once,ignore::PendingDeprecationWarning,ignore::ImportWarning:backports
# DeprecationWarning is disabled in dj32 tox env as Django 3.2
# deprecated Django 2.2 features. This workaround is just to reduce
# the number of warnings due to this change.
# It should be dropped when we drop Django 2.2 support.
dj32: PYTHONWARNINGS = once,ignore::PendingDeprecationWarning,ignore::DeprecationWarning
allowlist_externals =
bash
@ -31,7 +26,7 @@ deps =
# Unit test for a local hacking rule requires hacking.
hacking>=3.0.1,<3.1.0 # Apache-2.0
commands =
dj32: pip install django>=3.2,<3.3
dj42: pip install django>=4.2,<4.3
find . -type f -name "*.pyc" -delete
bash {toxinidir}/tools/unit_tests.sh {toxinidir} {posargs}