Fix issues related to py312 compatibility

Summary of changes:
- Bump flake8 from 3.9.2 to 7.1.1
- Remove pinning for setuptools
- Add py312 section to tox.ini [testenv]
- Fix unit test method assertEquals to assertEqual

Change-Id: I4582855a8232a428e3d31bcc6c2dd43691daf784
This commit is contained in:
Myles Penner 2024-08-19 15:19:34 -07:00
parent 7f2bfa0e04
commit ebe9d286ee
4 changed files with 15 additions and 11 deletions

View File

@ -4,7 +4,6 @@
# https://github.com/openstack-charmers/release-tools
#
pyparsing<3.0.0 # aodhclient is pinned in zaza and needs pyparsing < 3.0.0, but cffi also needs it, so pin here.
setuptools<50.0.0 # https://github.com/pypa/setuptools/commit/04e3df22df840c6bb244e9b27bc56750c44b7c85
stestr>=2.2.0

View File

@ -63,6 +63,11 @@ basepython = python3
deps = -r{toxinidir}/test-requirements.txt
commands = stestr run --slowest {posargs}
[testenv:py312]
basepython = python3.12
deps = -r{toxinidir}/test-requirements.txt
commands = stestr run --slowest {posargs}
[testenv:py310]
basepython = python3.10
deps = -r{toxinidir}/test-requirements.txt
@ -70,7 +75,7 @@ commands = stestr run --slowest {posargs}
[testenv:pep8]
basepython = python3
deps = flake8==3.9.2
deps = flake8==7.1.1
git+https://github.com/juju/charm-tools.git
commands = flake8 {posargs} src unit_tests

View File

@ -74,9 +74,9 @@ class TestAPICrud(test_utils.PatchHelper):
def test_endpoint_type(self):
self.patch_object(api_crud.ch_core.hookenv, 'config')
self.config.return_value = False
self.assertEquals(api_crud.endpoint_type(), 'publicURL')
self.assertEqual(api_crud.endpoint_type(), 'publicURL')
self.config.return_value = True
self.assertEquals(api_crud.endpoint_type(), 'internalURL')
self.assertEqual(api_crud.endpoint_type(), 'internalURL')
def test_session_from_identity_service(self):
self.patch_object(api_crud, 'keystone_identity')
@ -158,11 +158,11 @@ class TestAPICrud(test_utils.PatchHelper):
with self.assertRaises(api_crud.DuplicateResource):
api_crud.lookup_hm_port(nc, 'fake-unit-name')
nc.list_ports.return_value = {'ports': ['first']}
self.assertEquals(
self.assertEqual(
api_crud.lookup_hm_port(nc, 'fake-unit-name'),
'first')
nc.list_ports.return_value = {}
self.assertEquals(
self.assertEqual(
api_crud.lookup_hm_port(nc, 'fake-unit-name'),
None)
@ -254,7 +254,7 @@ class TestAPICrud(test_utils.PatchHelper):
self.patch_object(api_crud, 'init_neutron_client')
self.patch_object(api_crud, 'lookup_hm_port')
self.lookup_hm_port.return_value = None
self.assertEquals(
self.assertEqual(
api_crud.is_hm_port_bound('ids', 'fake-unit-name'), None)
self.lookup_hm_port.assert_called_once_with(
mock.ANY, 'fake-unit-name')
@ -386,8 +386,8 @@ class TestAPICrud(test_utils.PatchHelper):
],
}
identity_service = mock.MagicMock()
self.assertEquals(api_crud.get_port_ip_unit_map(identity_service),
{'lb-0': '2001:db8:42::1', 'lb-1': '2001:db8:42::2'})
self.assertEqual(api_crud.get_port_ip_unit_map(identity_service),
{'lb-0': '2001:db8:42::1', 'lb-1': '2001:db8:42::2'})
self.init_neutron_client.assert_called_once_with(
self.session_from_identity_service())

View File

@ -121,8 +121,8 @@ class TestOctaviaCharm(Helper):
# remove the 'is_flag_set' patch so the tests can use it
self._patches['is_flag_set'].stop()
setattr(self, 'is_flag_set', None)
del(self._patches['is_flag_set'])
del(self._patches_start['is_flag_set'])
del self._patches['is_flag_set']
del self._patches_start['is_flag_set']
def test_optional_ovn_provider_driver(self):
self.assertFalse('octavia-driver-agent' in self.target.packages)