From cc2b68548da8e556d9698ac071d51d846e233da9 Mon Sep 17 00:00:00 2001 From: Misbah Anjum N Date: Thu, 6 Jun 2024 08:40:13 -0500 Subject: [PATCH] Fix Syntax warnings on running ./op-test Currently there are syntax warnings present in the code while running ./op-test test cases. These syntax warnings are about using "==" and "!=" in place of "is" and "is not" respectively This simple patch will eliminate the syntax warnings Signed-off-by: Misbah Anjum N --- common/OpTestHMC.py | 2 +- common/OpTestInstallUtil.py | 6 +++--- testcases/OpTestFastReboot.py | 2 +- testcases/OpTestHMIHandling.py | 2 +- testcases/OpalMsglog.py | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/common/OpTestHMC.py b/common/OpTestHMC.py index f42466036..88ae035b4 100644 --- a/common/OpTestHMC.py +++ b/common/OpTestHMC.py @@ -381,7 +381,7 @@ def get_ioslots_assigned_to_lpar(self, lpar_profile=None): f" --filter 'lpar_names={self.lpar_name}," f"profile_names={lpar_profile}' -F io_slots") log.info(f"assigned_io_slots:{assigned_io_slots}") - return [] if assigned_io_slots is "none" \ + return [] if assigned_io_slots == "none" \ else assigned_io_slots[0].replace('"', "").split(",") def get_lpar_name_for_ioslot(self, ioslot): diff --git a/common/OpTestInstallUtil.py b/common/OpTestInstallUtil.py index c4de5a7e6..1d03a23c1 100644 --- a/common/OpTestInstallUtil.py +++ b/common/OpTestInstallUtil.py @@ -90,7 +90,7 @@ def wait_for_network(self): return True except CommandFailed as cf: log.debug("wait_for_network CommandFailed={}".format(cf)) - if cf.exitcode is 1: + if cf.exitcode == 1: time.sleep(5) retry = retry - 1 pass @@ -118,7 +118,7 @@ def ping_network(self): if retry == 1: log.debug("ping_network raise cf={}".format(cf)) raise cf - if cf.exitcode is 1: + if cf.exitcode == 1: time.sleep(5) retry = retry - 1 log.debug( @@ -217,7 +217,7 @@ def get_server_ip(self): break except CommandFailed as cf: log.debug("get_server_ip CommandFailed cf={}".format(cf)) - if cf.exitcode is 1: + if cf.exitcode == 1: time.sleep(1) retry = retry - 1 pass diff --git a/testcases/OpTestFastReboot.py b/testcases/OpTestFastReboot.py index d42f3944f..a802e3e92 100644 --- a/testcases/OpTestFastReboot.py +++ b/testcases/OpTestFastReboot.py @@ -118,7 +118,7 @@ def runTest(self): "/proc/device-tree/ibm,opal/fast-reboot: {}" .format(fast_reboot_state[:-1])) except CommandFailed as cf: - if cf.exitcode is not 1: + if cf.exitcode != 1: raise cf cpu = ''.join(c.run_command( diff --git a/testcases/OpTestHMIHandling.py b/testcases/OpTestHMIHandling.py index 4f42e3485..9a61e3d64 100644 --- a/testcases/OpTestHMIHandling.py +++ b/testcases/OpTestHMIHandling.py @@ -213,7 +213,7 @@ def disable_cpu_idle_states(self): states = self.cv_HOST.host_run_command( "find /sys/devices/system/cpu/cpu*/cpuidle/state* -type d | cut -d'/' -f8 | sort -u | sed -e 's/^state//'", console=1) for state in states: - if state is "0": + if state == "0": try: self.cv_HOST.host_run_command( "cpupower idle-set -e 0", console=1) diff --git a/testcases/OpalMsglog.py b/testcases/OpalMsglog.py index 2408a5b3a..be71b5876 100644 --- a/testcases/OpalMsglog.py +++ b/testcases/OpalMsglog.py @@ -127,7 +127,7 @@ def runTest(self): self.assertTrue(len(log_entries) == 0, "Warnings/Errors in OPAL log:\n%s" % msg) except CommandFailed as cf: - if cf.exitcode is 1 and len(cf.output) is 0: + if cf.exitcode == 1 and len(cf.output) == 0: # We have no warnings/errors! pass else: