From 83a74bfac089bdcfedd73eb65e407e5553e47a09 Mon Sep 17 00:00:00 2001 From: Felipe Reyes Date: Tue, 23 May 2023 15:28:36 -0400 Subject: [PATCH 1/6] Add Python 3.11 support Summary of changes: - Bump up lower constraint on tenacity - Add python 3.11 to the testing matrix --- .github/workflows/tox.yaml | 2 +- requirements.txt | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tox.yaml b/.github/workflows/tox.yaml index fdd0ee956..91da60f64 100644 --- a/.github/workflows/tox.yaml +++ b/.github/workflows/tox.yaml @@ -34,7 +34,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.7', '3.8', '3.9', '3.10'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] steps: - uses: actions/checkout@v1 diff --git a/requirements.txt b/requirements.txt index faffe82cc..a6de8f2ad 100644 --- a/requirements.txt +++ b/requirements.txt @@ -28,7 +28,7 @@ python-neutronclient python-novaclient python-octaviaclient python-swiftclient -tenacity +tenacity>8.2.0 paramiko python-libmaas requests<2.26 # pin for py3.5 support diff --git a/setup.py b/setup.py index 87445e411..a527b215f 100644 --- a/setup.py +++ b/setup.py @@ -39,7 +39,7 @@ 'juju<3.0', 'juju-wait', 'PyYAML', - 'tenacity', + 'tenacity>8.2.0', 'python-libmaas', ] From 55c3f3f94ac064eab7755d88b82f641f57bcc4a4 Mon Sep 17 00:00:00 2001 From: Felipe Reyes Date: Tue, 23 May 2023 15:36:23 -0400 Subject: [PATCH 2/6] Unpin pip and virtualenv --- pip.sh | 3 --- tox.ini | 30 +++++++++++++----------------- 2 files changed, 13 insertions(+), 20 deletions(-) delete mode 100755 pip.sh diff --git a/pip.sh b/pip.sh deleted file mode 100755 index 63b05f7de..000000000 --- a/pip.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -pip install pip==20.2.3 -pip "$@" diff --git a/tox.ini b/tox.ini index 26566bc55..dcd65b497 100644 --- a/tox.ini +++ b/tox.ini @@ -2,27 +2,23 @@ envlist = pep8,py3 skipsdist = True -# NOTES: -# * We avoid the new dependency resolver by pinning pip < 20.3, see -# https://github.com/pypa/pip/issues/9187 -# * Pinning dependencies requires tox >= 3.2.0, see -# https://tox.readthedocs.io/en/latest/config.html#conf-requires -# * It is also necessary to pin virtualenv as a newer virtualenv would still -# lead to fetching the latest pip in the func* tox targets, see -# https://stackoverflow.com/a/38133283 -requires = pip < 20.3 - virtualenv < 20.0 # NOTE: https://wiki.canonical.com/engineering/OpenStack/InstallLatestToxOnOsci minversion = 3.2.0 [testenv] -setenv = VIRTUAL_ENV={envdir} - PYTHONHASHSEED=0 -whitelist_external = juju -passenv = HOME TERM CS_* OS_* TEST_* -deps = -r{toxinidir}/test-requirements.txt -install_command = - {toxinidir}/pip.sh install {opts} {packages} +setenv = + VIRTUAL_ENV={envdir} + PYTHONHASHSEED=0 +allowlist_external = + juju +passenv = + HOME + TERM + CS_* + OS_* + TEST_* +deps = + -r{toxinidir}/test-requirements.txt commands = nosetests --with-coverage --processes=0 --cover-package=zaza {posargs} {toxinidir}/unit_tests [testenv:py3] From ac2594f23e0b323ee90d9b7c46c6cc2bf5e8ee4c Mon Sep 17 00:00:00 2001 From: Felipe Reyes Date: Wed, 24 May 2023 16:24:32 -0400 Subject: [PATCH 3/6] Bump up tenacity to a version compatible with py311 --- test-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-requirements.txt b/test-requirements.txt index a4a067b23..eee08e0f4 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -16,6 +16,6 @@ jinja2 keystoneauth1 oslo.config python-novaclient -tenacity +tenacity>8.2.0 # pinned until 3.0 regressions are handled: https://github.com/openstack-charmers/zaza/issues/545 juju<3.0 From 4b0d23ec92e1d3084dfaa79373af39a959cbdaa1 Mon Sep 17 00:00:00 2001 From: Felipe Reyes Date: Wed, 24 May 2023 16:25:24 -0400 Subject: [PATCH 4/6] Migrate from nosetest to pytest nosetest has been deprecated long time ago, adopting a more established unit test runner give us less problems as we move forward. --- test-requirements.txt | 7 +++---- tox.ini | 2 +- unit_tests/test_zaza_model.py | 2 ++ 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/test-requirements.txt b/test-requirements.txt index eee08e0f4..4eaa578bd 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -5,10 +5,9 @@ flake8-per-file-ignores pydocstyle<4.0.0 coverage mock>=1.2 -# For some reason the PyPi distributed wheel of nose differ from the one on -# GitHub, and it does not work with Python 3.10. -nose>=1.3.7;python_version<'3.10' -git+https://github.com/nose-devs/nose.git@release_1.3.7#egg=nose;python_version=='3.10' +pytest +pytest-cov +pytest-asyncio # TODO: these requirements should be mocked out in unit_tests/__init__.py async_generator diff --git a/tox.ini b/tox.ini index dcd65b497..1a7963a2d 100644 --- a/tox.ini +++ b/tox.ini @@ -19,7 +19,7 @@ passenv = TEST_* deps = -r{toxinidir}/test-requirements.txt -commands = nosetests --with-coverage --processes=0 --cover-package=zaza {posargs} {toxinidir}/unit_tests +commands = pytest --cov=./zaza/ {posargs} {toxinidir}/unit_tests [testenv:py3] basepython = python3 diff --git a/unit_tests/test_zaza_model.py b/unit_tests/test_zaza_model.py index a57f4d4b8..974519ace 100644 --- a/unit_tests/test_zaza_model.py +++ b/unit_tests/test_zaza_model.py @@ -32,6 +32,7 @@ import concurrent import datetime import mock +import pytest import yaml import unit_tests.utils as ut_utils @@ -100,6 +101,7 @@ def tearDownModule(): }}}}}} +@pytest.mark.asyncio class TestModel(ut_utils.BaseTestCase): def setUp(self): From a9d681259623b915295bdeb2e265d29ed5a4cea2 Mon Sep 17 00:00:00 2001 From: Felipe Reyes Date: Wed, 24 May 2023 16:35:54 -0400 Subject: [PATCH 5/6] Bump up flake8 Fixes `AttributeError: 'FlakesChecker' object has no attribute 'CONSTANT'` --- test-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-requirements.txt b/test-requirements.txt index 4eaa578bd..f4506cf5f 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,5 +1,5 @@ aiounittest -flake8>=2.2.4 +flake8>=5 # Python 3.8 compatibility in pyflakes 2.1.0+ flake8-docstrings flake8-per-file-ignores pydocstyle<4.0.0 From 2483be5b2babb64a864f619d5a6ccaf0a59d0527 Mon Sep 17 00:00:00 2001 From: Felipe Reyes Date: Wed, 24 May 2023 16:48:34 -0400 Subject: [PATCH 6/6] Add pytest.mark.asyncio --- unit_tests/test_zaza_controller.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/unit_tests/test_zaza_controller.py b/unit_tests/test_zaza_controller.py index 389defd8a..778aacb80 100644 --- a/unit_tests/test_zaza_controller.py +++ b/unit_tests/test_zaza_controller.py @@ -13,6 +13,7 @@ # limitations under the License. import mock +import pytest import unittest import unit_tests.utils as ut_utils @@ -25,6 +26,7 @@ def tearDownModule(): zaza.clean_up_libjuju_thread() +@pytest.mark.asyncio class TestController(ut_utils.BaseTestCase): def setUp(self):