From 2312a6c9767de9d7fcb73b766c61e8f925ceeb88 Mon Sep 17 00:00:00 2001 From: James Page Date: Mon, 22 Jul 2024 11:18:05 +0100 Subject: [PATCH] Fix compat with Python 3.12 assertEquals -> assertEqual (the former is no longer supported). --- unit_tests/test_zaza.py | 12 ++++++------ unit_tests/test_zaza_model.py | 12 ++++++------ .../utilities/test_zaza_utilities_launchpad.py | 6 +++--- unit_tests/utilities/test_zaza_utilities_maas.py | 10 +++++----- .../utilities/test_zaza_utilities_machine_os.py | 4 ++-- .../utilities/test_zaza_utilities_networking.py | 4 ++-- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/unit_tests/test_zaza.py b/unit_tests/test_zaza.py index 1df880c84..158ffac44 100644 --- a/unit_tests/test_zaza.py +++ b/unit_tests/test_zaza.py @@ -55,9 +55,9 @@ def num4(): return 4 with mock.patch.object(zaza, 'RUN_LIBJUJU_IN_THREAD', new=False): - self.assertEquals(zaza.run(one), 1) - self.assertEquals(zaza.run(one, two), 2) - self.assertEquals(zaza.run(one, two, add1(2)), 3) - self.assertEquals(zaza.run(), None) - self.assertEquals(zaza.run(num4), 4) - self.assertEquals(zaza.run(num4()), 4) + self.assertEqual(zaza.run(one), 1) + self.assertEqual(zaza.run(one, two), 2) + self.assertEqual(zaza.run(one, two, add1(2)), 3) + self.assertEqual(zaza.run(), None) + self.assertEqual(zaza.run(num4), 4) + self.assertEqual(zaza.run(num4()), 4) diff --git a/unit_tests/test_zaza_model.py b/unit_tests/test_zaza_model.py index b66f1ceb8..018631a37 100644 --- a/unit_tests/test_zaza_model.py +++ b/unit_tests/test_zaza_model.py @@ -1453,7 +1453,7 @@ def unit_wl_status(_model, unit, states): model.wait_for_application_states('modelname', timeout=1, max_resolve_count=3) self.assertFalse(self.system_ready) - self.assertEquals(self.async_resolve_units.call_count, 3) + self.assertEqual(self.async_resolve_units.call_count, 3) def test_wait_for_application_states_retries_non_retryable(self): self.patch_object(model, 'check_model_for_hard_errors') @@ -1512,7 +1512,7 @@ def unit_wl_status(_model, unit, states): with mock.patch.object(zaza, 'RUN_LIBJUJU_IN_THREAD', new=False): model.wait_for_application_states('modelname', timeout=500, max_resolve_count=3) - self.assertEquals(self.async_resolve_units.call_count, 2) + self.assertEqual(self.async_resolve_units.call_count, 2) self.async_block_until_unit_wl_status.assert_has_calls([ mock.call('app/2', 'error', 'modelname', negate_match=True, timeout=60), @@ -2980,7 +2980,7 @@ async def test_async_get_cloud_data(self): 'fake-cred-name', 'fake-cred') result = await model.async_get_cloud_data() self.assertIsInstance(result, model.CloudData) - self.assertEquals(result.cloud_name, mock.ANY) - self.assertEquals(result.cloud, mock.ANY) - self.assertEquals(result.credential_name, 'fake-cred-name') - self.assertEquals(result.credential, 'fake-cred') + self.assertEqual(result.cloud_name, mock.ANY) + self.assertEqual(result.cloud, mock.ANY) + self.assertEqual(result.credential_name, 'fake-cred-name') + self.assertEqual(result.credential, 'fake-cred') diff --git a/unit_tests/utilities/test_zaza_utilities_launchpad.py b/unit_tests/utilities/test_zaza_utilities_launchpad.py index b25e130e9..47f366fa7 100644 --- a/unit_tests/utilities/test_zaza_utilities_launchpad.py +++ b/unit_tests/utilities/test_zaza_utilities_launchpad.py @@ -27,7 +27,7 @@ def test_get_ubuntu_series(self): r = unittest.mock.MagicMock() r.text = json.dumps(expect) self.get.return_value = r - self.assertEquals( + self.assertEqual( launchpad.get_ubuntu_series(), expect, ) @@ -40,7 +40,7 @@ def test_get_ubuntu_series_by_version(self): self.get_ubuntu_series.return_value = { 'entries': [{'version': 'fakeVersion'}]} - self.assertEquals( + self.assertEqual( launchpad.get_ubuntu_series_by_version(), {'fakeVersion': {'version': 'fakeVersion'}}) @@ -50,6 +50,6 @@ def test_get_ubuntu_series_by_name(self): self.get_ubuntu_series.return_value = { 'entries': [{'name': 'fakeName'}]} - self.assertEquals( + self.assertEqual( launchpad.get_ubuntu_series_by_name(), {'fakeName': {'name': 'fakeName'}}) diff --git a/unit_tests/utilities/test_zaza_utilities_maas.py b/unit_tests/utilities/test_zaza_utilities_maas.py index 94acdb9da..0890fd221 100644 --- a/unit_tests/utilities/test_zaza_utilities_maas.py +++ b/unit_tests/utilities/test_zaza_utilities_maas.py @@ -94,7 +94,7 @@ async def af(): def test_get_macs_from_cidr(self): try: self.maxDiff = None - self.assertEquals( + self.assertEqual( maas.get_macs_from_cidr(self.maas_client, '192.0.2.0/24'), [ maas.MachineInterfaceMac( @@ -110,7 +110,7 @@ def test_get_macs_from_cidr(self): '192.0.2.0/24', mock.ANY), ]) - self.assertEquals( + self.assertEqual( maas.get_macs_from_cidr(self.maas_client, '192.0.2.0/24', link_mode=maas.LinkMode.LINK_UP), [ @@ -121,7 +121,7 @@ def test_get_macs_from_cidr(self): '192.0.2.0/24', maas.LinkMode.LINK_UP), ]) - self.assertEquals( + self.assertEqual( maas.get_macs_from_cidr(self.maas_client, '192.0.2.0/24', link_mode=maas.LinkMode.AUTO), [ @@ -132,7 +132,7 @@ def test_get_macs_from_cidr(self): '192.0.2.0/24', maas.LinkMode.AUTO), ]) - self.assertEquals( + self.assertEqual( maas.get_macs_from_cidr(self.maas_client, '198.51.100.0/24'), [ maas.MachineInterfaceMac( @@ -152,7 +152,7 @@ def test_get_macs_from_cidr(self): async def fget(*args): return self.machine2 self.maas_client.machines.get.side_effect = fget - self.assertEquals( + self.assertEqual( maas.get_macs_from_cidr(self.maas_client, '198.51.100.0/24', machine_id=self.machine2.system_id), [ diff --git a/unit_tests/utilities/test_zaza_utilities_machine_os.py b/unit_tests/utilities/test_zaza_utilities_machine_os.py index 50ba6a313..814f672fb 100644 --- a/unit_tests/utilities/test_zaza_utilities_machine_os.py +++ b/unit_tests/utilities/test_zaza_utilities_machine_os.py @@ -72,7 +72,7 @@ def test_add_netdevsim(self): self.patch_object(machine_os_utils.zaza.utilities.juju, 'remote_run') result = machine_os_utils.add_netdevsim( 'unit', 10, 2, model_name='model') - self.assertEquals(result, ['eni10np1', 'eni10np2']) + self.assertEqual(result, ['eni10np1', 'eni10np2']) self.install_modules_extra.assert_called_once_with( 'unit', model_name='model') self.load_kernel_module.assert_called_once_with( @@ -139,7 +139,7 @@ def test_get_hv_application(self): self.get_config_options.return_value = { machine_os_utils.HV_APPLICATION_KEY: 'someApp' } - self.assertEquals(machine_os_utils.get_hv_application(), 'someApp') + self.assertEqual(machine_os_utils.get_hv_application(), 'someApp') def test_reboot_hvs(self): # No hv_application diff --git a/unit_tests/utilities/test_zaza_utilities_networking.py b/unit_tests/utilities/test_zaza_utilities_networking.py index a070149a8..db5aef7e8 100644 --- a/unit_tests/utilities/test_zaza_utilities_networking.py +++ b/unit_tests/utilities/test_zaza_utilities_networking.py @@ -19,8 +19,8 @@ class TestUtils(unittest.TestCase): def test_format_addr(self): - self.assertEquals('1.2.3.4', network_utils.format_addr('1.2.3.4')) - self.assertEquals( + self.assertEqual('1.2.3.4', network_utils.format_addr('1.2.3.4')) + self.assertEqual( '[2001:db8::42]', network_utils.format_addr('2001:db8::42')) with self.assertRaises(ValueError): network_utils.format_addr('999.999.999.999')