diff --git a/tests/hwsim/fst_module_aux.py b/tests/hwsim/fst_module_aux.py index 1468b8651..58aabc5e3 100644 --- a/tests/hwsim/fst_module_aux.py +++ b/tests/hwsim/fst_module_aux.py @@ -438,7 +438,7 @@ class FstDevice: if event['type'] in events_to_ignore: continue elif len(events_to_count) > 0: - if not event['type'] in events_to_count: + if event['type'] not in events_to_count: continue return event diff --git a/tests/hwsim/hostapd.py b/tests/hwsim/hostapd.py index 3c031e952..7578159f1 100644 --- a/tests/hwsim/hostapd.py +++ b/tests/hwsim/hostapd.py @@ -85,17 +85,17 @@ class HostapdGlobal: if driver: cmd += " " + driver res = self.request(cmd) - if not "OK" in res: + if "OK" not in res: raise Exception("Could not add hostapd interface " + ifname) def add_iface(self, ifname, confname): res = self.request("ADD " + ifname + " config=" + confname) - if not "OK" in res: + if "OK" not in res: raise Exception("Could not add hostapd interface") def add_bss(self, phy, confname, ignore_error=False): res = self.request("ADD bss_config=" + phy + ":" + confname) - if not "OK" in res: + if "OK" not in res: if not ignore_error: raise Exception("Could not add hostapd BSS") @@ -187,7 +187,7 @@ class Hostapd: return "PONG" in self.request("PING") def set(self, field, value): - if not "OK" in self.request("SET " + field + " " + value): + if "OK" not in self.request("SET " + field + " " + value): raise Exception("Failed to set hostapd parameter " + field) def set_defaults(self): @@ -233,11 +233,11 @@ class Hostapd: self.set("wep_key0", key) def enable(self): - if not "OK" in self.request("ENABLE"): + if "OK" not in self.request("ENABLE"): raise Exception("Failed to enable hostapd interface " + self.ifname) def disable(self): - if not "OK" in self.request("DISABLE"): + if "OK" not in self.request("DISABLE"): raise Exception("Failed to disable hostapd interface " + self.ifname) def dump_monitor(self): diff --git a/tests/hwsim/run-tests.py b/tests/hwsim/run-tests.py index 9161576dc..dbc02923b 100755 --- a/tests/hwsim/run-tests.py +++ b/tests/hwsim/run-tests.py @@ -138,7 +138,7 @@ class DataCollector(object): stderr=open('/dev/null', 'w'), cwd=self._logdir) l = self._trace_cmd.stdout.read(7) - while self._trace_cmd.poll() is None and not 'STARTED' in l: + while self._trace_cmd.poll() is None and 'STARTED' not in l: l += self._trace_cmd.stdout.read(1) res = self._trace_cmd.returncode if res: @@ -254,7 +254,7 @@ def main(): if args.tests: fail = False for t in args.tests: - if not t in test_names: + if t not in test_names: print('Invalid arguments - test "%s" not known' % t) fail = True if fail: @@ -295,7 +295,7 @@ def main(): for t in tests: name = t.__name__.replace('test_', '', 1) if args.testmodules: - if not t.__module__.replace('test_', '', 1) in args.testmodules: + if t.__module__.replace('test_', '', 1) not in args.testmodules: continue tests_to_run.append(t) diff --git a/tests/hwsim/test_ap_vlan.py b/tests/hwsim/test_ap_vlan.py index 60908e24d..513273e19 100644 --- a/tests/hwsim/test_ap_vlan.py +++ b/tests/hwsim/test_ap_vlan.py @@ -362,14 +362,14 @@ def ap_vlan_iface_test_and_prepare_environ(): subprocess.call(['ifconfig', 'dummy0', 'up']) ifaces = netifaces.interfaces() - if not("dummy0" in ifaces): + if "dummy0" not in ifaces: raise HwsimSkip("failed to add dummy0 - missing kernel config DUMMY ?") subprocess.call(['ip', 'link', 'add', 'link', 'dummy0', 'name', 'dummy0.1', 'type', 'vlan', 'id', '1']) ifaces = netifaces.interfaces() - if not("dummy0.1" in ifaces): + if "dummy0.1" not in ifaces: raise HwsimSkip("failed to add dummy0.1 - missing kernel config VLAN_8021Q ?") subprocess.call(['ip', 'link', 'del', 'dummy0.1']) @@ -423,7 +423,7 @@ def ap_vlan_iface_cleanup_multibss(dev, apdev, cfgfile): scan_freq="2412") ifaces = netifaces.interfaces() - if not("brvlan1" in ifaces): + if "brvlan1" not in ifaces: raise Exception("bridge brvlan1 was not created") hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan1") @@ -458,7 +458,7 @@ def ap_vlan_iface_cleanup_multibss(dev, apdev, cfgfile): raise Exception("Unexpected state after reauth: " + state) ifaces = netifaces.interfaces() - if not ("brvlan1" in ifaces): + if "brvlan1" not in ifaces: raise Exception("bridge brvlan1 has been removed too early") hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan2", diff --git a/tests/hwsim/test_fst_module.py b/tests/hwsim/test_fst_module.py index 7e7f09605..ffa216f5c 100644 --- a/tests/hwsim/test_fst_module.py +++ b/tests/hwsim/test_fst_module.py @@ -238,7 +238,7 @@ def fst_initiate_session(apdev, test_params, bad_param_type, init_on_ap): initiator.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"]) setup_event = responder.wait_for_session_event(5, [], ['EVENT_FST_SETUP']) - if not 'id' in setup_event: + if 'id' not in setup_event: raise Exception("No session id in FST setup event") responder.send_session_setup_response(str(setup_event['id']), "reject") @@ -2233,7 +2233,7 @@ def test_fst_session_respond_fail(dev, apdev, test_params): sta1.send_session_setup_request(sid) sta1.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"]) ev = ap1.wait_for_session_event(5, [], ['EVENT_FST_SETUP']) - if not 'id' in ev: + if 'id' not in ev: raise Exception("No session id in FST setup event") # Disconnect STA to make SESSION_RESPOND fail due to no peer found sta = sta1.get_instance() diff --git a/tests/hwsim/test_hs20_filter.py b/tests/hwsim/test_hs20_filter.py index 545751c59..41a9aea5b 100644 --- a/tests/hwsim/test_hs20_filter.py +++ b/tests/hwsim/test_hs20_filter.py @@ -33,7 +33,7 @@ class IPAssign(object): # wait for DAD to finish while True: o = subprocess.check_output(self._cmd + ['show', 'tentative', 'dev', self._iface]).decode() - if not self._addr in o: + if self._addr not in o: break time.sleep(0.1) def __exit__(self, type, value, traceback): diff --git a/tests/hwsim/test_ocv.py b/tests/hwsim/test_ocv.py index 5f5d91550..9b8683746 100644 --- a/tests/hwsim/test_ocv.py +++ b/tests/hwsim/test_ocv.py @@ -720,9 +720,9 @@ class STAConnection: freq = params.pop("freq") if sta_params is None: sta_params = dict() - if not "ocv" in sta_params: + if "ocv" not in sta_params: sta_params["ocv"] = "1" - if not "ieee80211w" in sta_params: + if "ieee80211w" not in sta_params: sta_params["ieee80211w"] = "1" params.update(hostapd.wpa2_params(ssid=self.ssid, diff --git a/tests/hwsim/test_p2p_service.py b/tests/hwsim/test_p2p_service.py index 3056d0f27..178e74e64 100644 --- a/tests/hwsim/test_p2p_service.py +++ b/tests/hwsim/test_p2p_service.py @@ -159,7 +159,7 @@ def test_p2p_service_discovery_fragmentation(dev): """P2P service discovery with fragmentation""" for dst in [ "00:00:00:00:00:00", dev[0].p2p_dev_addr() ]: ev = run_sd(dev, dst, "02000001", fragment=True) - if not "long response" in ev: + if "long response" not in ev: if "0b5f6166706f766572746370c00c000c01" not in ev: raise Exception("Unexpected service discovery response contents (Bonjour)") if "496e7465726e6574" not in ev: diff --git a/tests/hwsim/test_rfkill.py b/tests/hwsim/test_rfkill.py index 8a2a5e2fa..775e2c4c6 100644 --- a/tests/hwsim/test_rfkill.py +++ b/tests/hwsim/test_rfkill.py @@ -154,7 +154,7 @@ def _test_rfkill_p2p_discovery(dev0, dev1): if dev0.get_status_field("wpa_state") != "INTERFACE_DISABLED" and dev1.get_status_field("wpa_state") != "INTERFACE_DISABLED": break - if not "OK" in dev0.p2p_listen(): + if "OK" not in dev0.p2p_listen(): raise Exception("P2P Listen failed after unblocking rfkill") if not dev1.discover_peer(addr0, social=True): diff --git a/tests/hwsim/test_suite_b.py b/tests/hwsim/test_suite_b.py index f4e3604b7..b0633d2ee 100644 --- a/tests/hwsim/test_suite_b.py +++ b/tests/hwsim/test_suite_b.py @@ -632,7 +632,7 @@ def test_openssl_ecdh_curves(dev, apdev): hapd.disable() hapd.set('openssl_ecdh_curves', 'foo') - if not "FAIL" in hapd.request("ENABLE"): + if "FAIL" not in hapd.request("ENABLE"): raise Exception("Invalid openssl_ecdh_curves value accepted") hapd.set('openssl_ecdh_curves', 'P-384') hapd.enable() diff --git a/tests/hwsim/test_wpas_config.py b/tests/hwsim/test_wpas_config.py index 6274abf1c..0f5797c5a 100644 --- a/tests/hwsim/test_wpas_config.py +++ b/tests/hwsim/test_wpas_config.py @@ -577,7 +577,7 @@ def test_wpas_config_file_key_mgmt(dev, apdev, params): "FT-FILS-SHA256", "FT-FILS-SHA384", "OWE", "DPP" ] supported_key_mgmts = dev[0].get_capability("key_mgmt") for key_mgmt in tests: - if key_mgmt == "WPA-EAP-SUITE-B-192" and not key_mgmt in supported_key_mgmts: + if key_mgmt == "WPA-EAP-SUITE-B-192" and key_mgmt not in supported_key_mgmts: logger.info("Skip unsupported " + key_mgmt) continue wpas.set_network(id, "key_mgmt", key_mgmt) diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index b447ba6a8..bd42350a6 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/tests/hwsim/wpasupplicant.py @@ -212,7 +212,7 @@ class WpaSupplicant: def reset(self): self.dump_monitor() res = self.request("FLUSH") - if not "OK" in res: + if "OK" not in res: logger.info("FLUSH to " + self.ifname + " failed: " + res) self.global_request("REMOVE_NETWORK all") self.global_request("SET p2p_no_group_iface 1") @@ -259,7 +259,7 @@ class WpaSupplicant: logger.info("No PING response from " + self.ifname + " after reset") def set(self, field, value): - if not "OK" in self.request("SET " + field + " " + value): + if "OK" not in self.request("SET " + field + " " + value): raise Exception("Failed to set wpa_supplicant parameter " + field) def add_network(self): @@ -969,7 +969,7 @@ class WpaSupplicant: if "tsid=%d" % (tsid) not in ev: raise Exception("ADDTS failed (invalid tsid in TSPEC-ADDED)") - if not (tsid, up) in self.tspecs(): + if (tsid, up) not in self.tspecs(): raise Exception("ADDTS failed (tsid not in tspec list)") def del_ts(self, tsid): @@ -1063,7 +1063,7 @@ class WpaSupplicant: if not no_wait: self.dump_monitor() res = self.request(cmd) - if not "OK" in res: + if "OK" not in res: raise Exception("Failed to trigger scan: " + str(res)) if no_wait: return