From 1a32d738decdc37f13f10c352f28442f000bb1c7 Mon Sep 17 00:00:00 2001 From: Adrian Vladu Date: Wed, 7 Sep 2022 17:17:41 +0300 Subject: [PATCH] opendev: bumped gates to python 3.9/3.10 Python 3.6/3.7 are no longer supported for the latest releasese of the OpenStack packages like oslo or coverage, thus switching to the Zed OpenStack release gates, which have support for 3.8/3.9/3.10 Python versions. For gates to pass, the docs required a defined language to be set ("en"), while the crypto unit tests required a method signature fix when running on Python 3.9/3.10. The version test__check_latest_version* unit tests started failing in a transient pattern because of the pbr.version.VersionInfo().release_string() throwing the following error: "NotImplementedError: cannot instantiate 'WindowsPath' on your system". This required to have the cloudbaseinit.version.get_version mocked for a reliable unit test run on Linux. Change-Id: I4748d1258c072c377825474e1116347b0a085c56 --- .zuul.yaml | 2 +- cloudbaseinit/tests/test_version.py | 13 +++++++++---- cloudbaseinit/tests/utils/test_crypt.py | 7 ++++--- doc/source/conf.py | 2 +- setup.cfg | 4 ++-- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.zuul.yaml b/.zuul.yaml index 2f201160..4ecc22f5 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -2,7 +2,7 @@ templates: - openstack-cover-jobs - build-openstack-docs-pti - - openstack-python3-ussuri-jobs + - openstack-python3-zed-jobs - build-release-notes-jobs-python3 post: jobs: diff --git a/cloudbaseinit/tests/test_version.py b/cloudbaseinit/tests/test_version.py index d56c1ed6..4108f1e6 100644 --- a/cloudbaseinit/tests/test_version.py +++ b/cloudbaseinit/tests/test_version.py @@ -78,8 +78,9 @@ class TestVersion(unittest.TestCase): thread = mock_thread.return_value thread.start.assert_called_once_with() + @mock.patch('cloudbaseinit.version.get_version') @mock.patch('cloudbaseinit.version._read_url') - def test__check_latest_version(self, mock_read_url): + def test__check_latest_version(self, mock_read_url, mock_ver): mock_read_url.return_value = {'new_version': 42} mock_callback = mock.Mock() @@ -87,8 +88,9 @@ class TestVersion(unittest.TestCase): mock_callback.assert_called_once_with(42) + @mock.patch('cloudbaseinit.version.get_version') @mock.patch('cloudbaseinit.version._read_url') - def test__check_latest_version_fails(self, mock_read_url): + def test__check_latest_version_fails(self, mock_read_url, mock_ver): mock_read_url.side_effect = Exception('no worky') mock_callback = mock.Mock() @@ -99,8 +101,9 @@ class TestVersion(unittest.TestCase): self.assertEqual(expected_logging, snatcher.output) self.assertFalse(mock_callback.called) + @mock.patch('cloudbaseinit.version.get_version') @mock.patch('cloudbaseinit.version._read_url') - def test__check_latest_version_no_content(self, mock_read_url): + def test__check_latest_version_no_content(self, mock_read_url, mock_ver): mock_read_url.return_value = None mock_callback = mock.Mock() @@ -108,8 +111,10 @@ class TestVersion(unittest.TestCase): self.assertFalse(mock_callback.called) + @mock.patch('cloudbaseinit.version.get_version') @mock.patch('cloudbaseinit.version._read_url') - def test__check_latest_version_no_new_version(self, mock_read_url): + def test__check_latest_version_no_new_version( + self, mock_read_url, mock_ver): mock_read_url.return_value = {'new_versio': 42} mock_callback = mock.Mock() diff --git a/cloudbaseinit/tests/utils/test_crypt.py b/cloudbaseinit/tests/utils/test_crypt.py index 565f4aeb..4abfaaa9 100644 --- a/cloudbaseinit/tests/utils/test_crypt.py +++ b/cloudbaseinit/tests/utils/test_crypt.py @@ -23,9 +23,10 @@ class TestOpenSSLException(unittest.TestCase): self._openssl = crypt.OpenSSLException() def test_get_openssl_error_msg(self): - expected_error_msg = u'error:00000000:lib(0):func(0):reason(0)' - error_msg = self._openssl._get_openssl_error_msg() - self.assertEqual(expected_error_msg, error_msg) + expected_err_msg = u'error:00000000:lib(0):func(0):reason(0)' + expected_err_msg_py10 = u'error:00000000:lib(0)::reason(0)' + err_msg = self._openssl._get_openssl_error_msg() + self.assertIn(err_msg, [expected_err_msg, expected_err_msg_py10]) class TestCryptManager(unittest.TestCase): diff --git a/doc/source/conf.py b/doc/source/conf.py index 0e64a443..e93664e4 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -73,7 +73,7 @@ release = version # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = None +language = "en" # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: diff --git a/setup.cfg b/setup.cfg index 33186b91..55f6d7a8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -15,9 +15,9 @@ classifier = Operating System :: OS Independent Programming Language :: Python Programming Language :: Python :: 3 - Programming Language :: Python :: 3.6 - Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 [files] packages =