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]
- Fixed unit test assertEquals method to assertEqual
- Renamed a conflicting class attribute

Change-Id: Ieb742a25e0f03a96e5e255cb56459c570ddcd67f
This commit is contained in:
Myles Penner 2024-08-21 16:33:16 +00:00
parent 2c9fb13e41
commit 63e6e23b24
6 changed files with 20 additions and 19 deletions

View File

@ -2,11 +2,6 @@
# within individual charm repos. See the 'global' dir contents for available # within individual charm repos. See the 'global' dir contents for available
# choices of *requirements.txt files for OpenStack Charms: # choices of *requirements.txt files for OpenStack Charms:
# https://github.com/openstack-charmers/release-tools # https://github.com/openstack-charmers/release-tools
#
# NOTE(lourot): This might look like a duplication of test-requirements.txt but
# some tox targets use only test-requirements.txt whereas charm-build uses only
# requirements.txt
setuptools<50.0.0 # https://github.com/pypa/setuptools/commit/04e3df22df840c6bb244e9b27bc56750c44b7c85
# NOTE: newer versions of cryptography require a Rust compiler to build, # NOTE: newer versions of cryptography require a Rust compiler to build,
# see # see

View File

@ -74,7 +74,7 @@ class BaseNeutronAPIPluginCharm(charms_openstack.charm.OpenStackCharm):
release_pkg = version_package = 'neutron-common' release_pkg = version_package = 'neutron-common'
# make sure we can write secrets readable by the ``neutron-server`` process # make sure we can write secrets readable by the ``neutron-server`` process
group = 'neutron' group = 'neutron'
db_migration_needed = False _db_migration_needed = False
# Neutron service plugins to add # Neutron service plugins to add
svc_plugins = [] svc_plugins = []
# Neutron service plugins to remove # Neutron service plugins to remove
@ -168,7 +168,7 @@ class BaseNeutronAPIPluginCharm(charms_openstack.charm.OpenStackCharm):
:returns: Whether DB migration is needed. :returns: Whether DB migration is needed.
:rtype: bool :rtype: bool
""" """
return self.db_migration_needed return self._db_migration_needed
def service_plugins(self, neutron_svc_plugins=None): def service_plugins(self, neutron_svc_plugins=None):
"""Provide list of service plugins for current OpenStack release. """Provide list of service plugins for current OpenStack release.

View File

@ -4,7 +4,6 @@
# https://github.com/openstack-charmers/release-tools # 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. 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 stestr>=2.2.0

View File

@ -65,6 +65,13 @@ deps =
-r{toxinidir}/test-requirements.txt -r{toxinidir}/test-requirements.txt
commands = stestr run --slowest {posargs} commands = stestr run --slowest {posargs}
[testenv:py312]
basepython = python3.12
deps =
-c {env:TEST_CONSTRAINTS_FILE:https://raw.githubusercontent.com/openstack-charmers/zaza-openstack-tests/master/constraints/constraints-2024.1.txt}
-r{toxinidir}/test-requirements.txt
commands = stestr run --slowest {posargs}
[testenv:py310] [testenv:py310]
basepython = python3.10 basepython = python3.10
deps = deps =
@ -74,7 +81,7 @@ commands = stestr run --slowest {posargs}
[testenv:pep8] [testenv:pep8]
basepython = python3 basepython = python3
deps = flake8==3.9.2 deps = flake8==7.1.1
git+https://github.com/juju/charm-tools.git git+https://github.com/juju/charm-tools.git
commands = flake8 {posargs} src unit_tests commands = flake8 {posargs} src unit_tests

View File

@ -219,7 +219,7 @@ class TestActions(test_utils.PatchHelper):
return parser return parser
self.ConfigParser.side_effect = _fakeparser self.ConfigParser.side_effect = _fakeparser
self.assertEquals( self.assertEqual(
actions.get_neutron_db_connection_string(), 'fake-connection') actions.get_neutron_db_connection_string(), 'fake-connection')
def test_offline_neutron_morph_db(self): def test_offline_neutron_morph_db(self):

View File

@ -28,14 +28,14 @@ class TestNeutronAPIPluginOvnConfigProperties(test_utils.PatchHelper):
def test_ovn_key(self): def test_ovn_key(self):
cls = mock.MagicMock() cls = mock.MagicMock()
self.assertEquals( self.assertEqual(
neutron_api_plugin_ovn.ovn_key(cls), neutron_api_plugin_ovn.ovn_key(cls),
os.path.join(neutron_api_plugin_ovn.NEUTRON_PLUGIN_ML2_DIR, os.path.join(neutron_api_plugin_ovn.NEUTRON_PLUGIN_ML2_DIR,
'key_host')) 'key_host'))
def test_ovn_cert(self): def test_ovn_cert(self):
cls = mock.MagicMock() cls = mock.MagicMock()
self.assertEquals( self.assertEqual(
neutron_api_plugin_ovn.ovn_cert(cls), neutron_api_plugin_ovn.ovn_cert(cls),
os.path.join(neutron_api_plugin_ovn.NEUTRON_PLUGIN_ML2_DIR, os.path.join(neutron_api_plugin_ovn.NEUTRON_PLUGIN_ML2_DIR,
'cert_host')) 'cert_host'))
@ -43,7 +43,7 @@ class TestNeutronAPIPluginOvnConfigProperties(test_utils.PatchHelper):
def test_ovn_ca_cert(self): def test_ovn_ca_cert(self):
cls = mock.MagicMock() cls = mock.MagicMock()
cls.charm_instance.name = 'neutron-api-plugin-ovn' cls.charm_instance.name = 'neutron-api-plugin-ovn'
self.assertEquals( self.assertEqual(
neutron_api_plugin_ovn.ovn_ca_cert(cls), neutron_api_plugin_ovn.ovn_ca_cert(cls),
os.path.join(neutron_api_plugin_ovn.NEUTRON_PLUGIN_ML2_DIR, os.path.join(neutron_api_plugin_ovn.NEUTRON_PLUGIN_ML2_DIR,
'neutron-api-plugin-ovn.crt')) 'neutron-api-plugin-ovn.crt'))
@ -126,7 +126,7 @@ class TestNeutronAPIPluginOvnCharm(Helper):
'lbaasv2', 'lbaasv2',
'ovn-router', 'ovn-router',
] ]
self.assertEquals(c.service_plugins(svc_plugins), expect) self.assertEqual(c.service_plugins(svc_plugins), expect)
def test_mechanism_drivers(self): def test_mechanism_drivers(self):
c = neutron_api_plugin_ovn.UssuriNeutronAPIPluginCharm() c = neutron_api_plugin_ovn.UssuriNeutronAPIPluginCharm()
@ -135,13 +135,13 @@ class TestNeutronAPIPluginOvnCharm(Helper):
'ovn', 'ovn',
'sriovnicswitch', 'sriovnicswitch',
] ]
self.assertEquals(c.mechanism_drivers(mech_drivers), expect) self.assertEqual(c.mechanism_drivers(mech_drivers), expect)
def test_tenant_network_types(self): def test_tenant_network_types(self):
c = neutron_api_plugin_ovn.UssuriNeutronAPIPluginCharm() c = neutron_api_plugin_ovn.UssuriNeutronAPIPluginCharm()
network_types = 'gre,vlan,flat,local' network_types = 'gre,vlan,flat,local'
expect = ['geneve', 'gre', 'vlan', 'flat', 'local'] expect = ['geneve', 'gre', 'vlan', 'flat', 'local']
self.assertEquals(c.tenant_network_types(network_types), expect) self.assertEqual(c.tenant_network_types(network_types), expect)
@mock.patch.object( @mock.patch.object(
neutron_api_plugin_ovn.charms_openstack.charm.OpenStackCharm, neutron_api_plugin_ovn.charms_openstack.charm.OpenStackCharm,
@ -163,7 +163,7 @@ class TestNeutronAPIPluginOvnCharm(Helper):
c = neutron_api_plugin_ovn.UssuriNeutronAPIPluginCharm() c = neutron_api_plugin_ovn.UssuriNeutronAPIPluginCharm()
# Assert that getter returns correct value # Assert that getter returns correct value
self.assertEquals(c.series, series) self.assertEqual(c.series, series)
mock_lsb_release.assert_called_once_with() mock_lsb_release.assert_called_once_with()
# Assert that getter does not call underlying functions multiple times # Assert that getter does not call underlying functions multiple times
@ -184,7 +184,7 @@ class TestNeutronAPIPluginOvnCharm(Helper):
default_pocket = c.ovn_default_pockets[series] default_pocket = c.ovn_default_pockets[series]
self.assertEquals(c.ovn_source, default_pocket) self.assertEqual(c.ovn_source, default_pocket)
def test_ovn_source_distro(self): def test_ovn_source_distro(self):
"""Test that 'ovn_source' property returns no UCA pocket. """Test that 'ovn_source' property returns no UCA pocket.
@ -195,7 +195,7 @@ class TestNeutronAPIPluginOvnCharm(Helper):
c = neutron_api_plugin_ovn.UssuriNeutronAPIPluginCharm() c = neutron_api_plugin_ovn.UssuriNeutronAPIPluginCharm()
c.options.ovn_source = 'distro' c.options.ovn_source = 'distro'
self.assertEquals(c.ovn_source, '') self.assertEqual(c.ovn_source, '')
def test_ovn_source_manual(self): def test_ovn_source_manual(self):
"""Test that 'ovn_source' property returns manually configured ppa. """Test that 'ovn_source' property returns manually configured ppa.