From 95d013f53051708bff40cc6f1b8da53c09d0eacb Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 3 Feb 2019 12:24:49 +0200 Subject: [PATCH] tests: Replace str.translate() with str.replace() This is needed for python3 since the two argument version of str.translate() is not available for unicode. Furthermore, these cases of delete colons from the string are simple enough for replace. Signed-off-by: Jouni Malinen --- tests/hwsim/test_ap_hs20.py | 4 ++-- tests/hwsim/test_cfg80211.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/hwsim/test_ap_hs20.py b/tests/hwsim/test_ap_hs20.py index ee4a7b020..c9bc63c77 100644 --- a/tests/hwsim/test_ap_hs20.py +++ b/tests/hwsim/test_ap_hs20.py @@ -1586,7 +1586,7 @@ def test_ap_hs20_disallow_aps(dev, apdev): dev[0].scan_for_bss(bssid, freq="2412") logger.info("Verify disallow_aps bssid") - dev[0].request("SET disallow_aps bssid " + bssid.translate(None, ':')) + dev[0].request("SET disallow_aps bssid " + bssid.replace(':', '')) dev[0].request("INTERWORKING_SELECT auto") ev = dev[0].wait_event(["INTERWORKING-NO-MATCH"], timeout=15) if ev is None: @@ -1605,7 +1605,7 @@ def test_ap_hs20_disallow_aps(dev, apdev): dev[0].request("SET disallow_aps ") interworking_select(dev[0], bssid, "home", freq="2412") - dev[0].request("SET disallow_aps bssid " + bssid.translate(None, ':')) + dev[0].request("SET disallow_aps bssid " + bssid.replace(':', '')) ret = dev[0].request("INTERWORKING_CONNECT " + bssid) if "FAIL" not in ret: raise Exception("INTERWORKING_CONNECT to disallowed BSS not rejected") diff --git a/tests/hwsim/test_cfg80211.py b/tests/hwsim/test_cfg80211.py index 2a84cd2df..0890984fc 100644 --- a/tests/hwsim/test_cfg80211.py +++ b/tests/hwsim/test_cfg80211.py @@ -70,7 +70,7 @@ def test_cfg80211_tx_frame(dev, apdev, params): dev[0].p2p_start_go(freq='2412') go = WpaSupplicant(dev[0].group_ifname) - frame = binascii.unhexlify("d0000000020000000100" + go.own_addr().translate(None, ':') + "02000000010000000409506f9a090001dd5e506f9a0902020025080401001f0502006414060500585804510b0906000200000000000b1000585804510b0102030405060708090a0b0d1d000200000000000108000000000000000000101100084465766963652041110500585804510bdd190050f204104a0001101012000200011049000600372a000120") + frame = binascii.unhexlify("d0000000020000000100" + go.own_addr().replace(':', '') + "02000000010000000409506f9a090001dd5e506f9a0902020025080401001f0502006414060500585804510b0906000200000000000b1000585804510b0102030405060708090a0b0d1d000200000000000108000000000000000000101100084465766963652041110500585804510bdd190050f204104a0001101012000200011049000600372a000120") ifindex = int(go.get_driver_status_field("ifindex")) res = nl80211_frame(go, ifindex, frame, freq=2422, duration=500, offchannel_tx_ok=True)