From 16474fcf24d22514ea4a170174266b71cdb3648b Mon Sep 17 00:00:00 2001 From: Brian Haley Date: Mon, 12 Feb 2024 21:32:25 -0500 Subject: [PATCH] Fix used-before-assignment warnings Moved some code around to avoid the warning. No functional change. TrivialFix Change-Id: I5451e411dccf639dcab50ed10edf0cf57edeac45 --- .../tests/unit/db/test_agentschedulers_db.py | 21 +++++++------------ .../unit/tests/test_post_mortem_debug.py | 1 + 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/neutron/tests/unit/db/test_agentschedulers_db.py b/neutron/tests/unit/db/test_agentschedulers_db.py index e7815dd684b..1a0862f99bc 100644 --- a/neutron/tests/unit/db/test_agentschedulers_db.py +++ b/neutron/tests/unit/db/test_agentschedulers_db.py @@ -1583,27 +1583,22 @@ class OvsDhcpAgentNotifierTestCase(test_agent.AgentDBTestMixIn, hosts = [DHCP_HOSTA, DHCP_HOSTC, DHCP_HOSTD] net, subnet, port = self._network_port_create(hosts) for host_call in self.dhcp_notifier_cast.call_args_list: + host_call = str(host_call) if ("'priority': " + str( dhcp_rpc_agent_api.PRIORITY_PORT_CREATE_HIGH) - in str(host_call)): - if DHCP_HOSTA in str(host_call): - expected_high_calls = self._notification_mocks( - [DHCP_HOSTA], net, subnet, port, - dhcp_rpc_agent_api.PRIORITY_PORT_CREATE_HIGH) + in host_call): + if DHCP_HOSTA in host_call: high_host = DHCP_HOSTA hosts.pop(0) - elif DHCP_HOSTC in str(host_call): - expected_high_calls = self._notification_mocks( - [DHCP_HOSTC], net, subnet, port, - dhcp_rpc_agent_api.PRIORITY_PORT_CREATE_HIGH) + elif DHCP_HOSTC in host_call: high_host = DHCP_HOSTC hosts.pop(1) - elif DHCP_HOSTD in str(host_call): - expected_high_calls = self._notification_mocks( - [DHCP_HOSTD], net, subnet, port, - dhcp_rpc_agent_api.PRIORITY_PORT_CREATE_HIGH) + elif DHCP_HOSTD in host_call: high_host = DHCP_HOSTD hosts.pop(2) + expected_high_calls = self._notification_mocks( + [high_host], net, subnet, port, + dhcp_rpc_agent_api.PRIORITY_PORT_CREATE_HIGH) expected_low_calls = self._notification_mocks( hosts, net, subnet, port, dhcp_rpc_agent_api.PRIORITY_PORT_CREATE_LOW) diff --git a/neutron/tests/unit/tests/test_post_mortem_debug.py b/neutron/tests/unit/tests/test_post_mortem_debug.py index 15244d94961..4a6e2076151 100644 --- a/neutron/tests/unit/tests/test_post_mortem_debug.py +++ b/neutron/tests/unit/tests/test_post_mortem_debug.py @@ -23,6 +23,7 @@ from neutron.tests import post_mortem_debug class TestTesttoolsExceptionHandler(base.BaseTestCase): def test_exception_handler(self): + exc_info = None try: self.fail() except Exception: