From 3afff6c6b8795fbd9ad71619dd103d63c6ef940b Mon Sep 17 00:00:00 2001 From: Javier-Tan <47554099+Javier-Tan@users.noreply.github.com> Date: Tue, 4 Feb 2025 04:26:18 +0000 Subject: [PATCH] [platform_tests/test_power_off_reboot.py] Prevent `output_watts` KeyError * Use .get to get output_watts with a default value if the key doesn't exist Signed-off-by: Javier Tan javiertan@microsoft.com --- tests/platform_tests/test_power_off_reboot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/platform_tests/test_power_off_reboot.py b/tests/platform_tests/test_power_off_reboot.py index 20b3f12f433..d203acf5c89 100644 --- a/tests/platform_tests/test_power_off_reboot.py +++ b/tests/platform_tests/test_power_off_reboot.py @@ -93,7 +93,7 @@ def test_power_off_reboot(duthosts, localhost, enum_supervisor_dut_hostname, con # If PDU supports returning output_watts, making sure that all PSUs has power. psu_to_pdus = get_grouped_pdus_by_psu(pdu_ctrl) for psu, pdus in psu_to_pdus.items(): - pytest_assert(any(pdu["output_watts"] != 0 for pdu in pdus), "Not all PSUs are getting power") + pytest_assert(any(int(pdu.get('output_watts', '1')) != 0 for pdu in pdus), "Not all PSUs are getting power") # Purpose of this list is to control sequence of turning on PSUs in power off testing. # If there are 2 PSUs, then 3 scenarios would be covered: