]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Python coding style cleanup (pylint3 unneeded-not)
authorJouni Malinen <jouni@codeaurora.org>
Fri, 15 Mar 2019 09:34:32 +0000 (11:34 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 15 Mar 2019 09:34:32 +0000 (11:34 +0200)
Use more readable "foo not in bar" construction for the couple of places
that did "not foo in bar".

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
12 files changed:
tests/hwsim/fst_module_aux.py
tests/hwsim/hostapd.py
tests/hwsim/run-tests.py
tests/hwsim/test_ap_vlan.py
tests/hwsim/test_fst_module.py
tests/hwsim/test_hs20_filter.py
tests/hwsim/test_ocv.py
tests/hwsim/test_p2p_service.py
tests/hwsim/test_rfkill.py
tests/hwsim/test_suite_b.py
tests/hwsim/test_wpas_config.py
tests/hwsim/wpasupplicant.py

index 1468b86518b5b437c8379c34da5c2561d676c3c7..58aabc5e3eaa26af4a4d635f49d76d43e661afd4 100644 (file)
@@ -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
 
index 3c031e952c6dfd9877d67d364dbdf57a2437308f..7578159f1d68178beba4ca2cef0b6d261ff7339a 100644 (file)
@@ -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):
index 9161576dc51be34c263d8f99b7a4053fa2eff0bf..dbc02923b0b62c3582859406feafe18aa8fe2e79 100755 (executable)
@@ -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)
 
index 60908e24dff47a01e99ce3f666917962a40ef86a..513273e19a9b3ce95c6939e7733109ee69871f34 100644 (file)
@@ -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",
index 7e7f096056f0e6d11c9670cd03fa322dc69bf865..ffa216f5cf411b3f2f0b4f4582233579a65818bb 100644 (file)
@@ -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()
index 545751c59933a49b7dfefe8b04b1ee4edfeebe20..41a9aea5b13fb59095f12ad1faeb6192cfbd2a8c 100644 (file)
@@ -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):
index 5f5d91550109b734eb23dbb5fb7de9638b8ac52c..9b8683746156140016ec10adbba6647bb45ef250 100644 (file)
@@ -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,
index 3056d0f274396396111fb11bbdb86fabd9970400..178e74e6476879ec7fac8cea21b77381dbf26a7c 100644 (file)
@@ -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:
index 8a2a5e2faa6d0eb0d91c0132a806a404914a3c50..775e2c4c6cbafe84a50efdc18ac998d76b5098da 100644 (file)
@@ -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):
index f4e3604b723e15eefcce0c6f3608b7bc833bd2be..b0633d2ee9b868bf376b4967836d4bd0a0cfeb86 100644 (file)
@@ -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()
index 6274abf1cdb7373fbb7c152822a4d257b72d2397..0f5797c5ad5bb0a5b6028ba7aa3bcc1ebb54632f 100644 (file)
@@ -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)
index b447ba6a88f9d70c08b9b3f512a1133ea30f6460..bd42350a67dac98485f2fb77ffc0414acbf087e1 100644 (file)
@@ -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