diff --git a/tests/gnmi/test_gnmi_smartswitch.py b/tests/gnmi/test_gnmi_smartswitch.py index 595fbca839..6378d8b523 100644 --- a/tests/gnmi/test_gnmi_smartswitch.py +++ b/tests/gnmi/test_gnmi_smartswitch.py @@ -40,11 +40,15 @@ def test_gnmi_appldb_01(duthosts, rand_one_dut_hostname, ptfhost): target = None result = duthost.shell("show chassis module status") headers = result['stdout_lines'][0].split() + name_idx = None + oper_status_idx = None for i, header in enumerate(headers): if header == "Name": name_idx = i if header == "Oper-Status": oper_status_idx = i + assert name_idx is not None, "Can't locate Name in the headers" + assert oper_status_idx is not None, "Can't locate Oper-Status in the headers" for line in result['stdout_lines']: module_status = line.split() if module_status[oper_status_idx] == "Online":