diff options
author | David Lechner <david@lechnology.com> | 2020-03-22 21:26:08 -0500 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2020-03-30 13:21:58 +1100 |
commit | 3dc324d3f1312e40d3a8ed87e7244966bb756f26 (patch) | |
tree | 94ff44f8eabba0039582c245b901173597edd11e /tests/wipy/wlan/wlan.py | |
parent | 488613bca6c460340ed2995ae5cafafe22d0bfff (diff) |
tests: Format all Python code with black, except tests in basics subdir.
This adds the Python files in the tests/ directory to be formatted with
./tools/codeformat.py. The basics/ subdirectory is excluded for now so we
aren't changing too much at once.
In a few places `# fmt: off`/`# fmt: on` was used where the code had
special formatting for readability or where the test was actually testing
the specific formatting.
Diffstat (limited to 'tests/wipy/wlan/wlan.py')
-rw-r--r-- | tests/wipy/wlan/wlan.py | 77 |
1 files changed, 39 insertions, 38 deletions
diff --git a/tests/wipy/wlan/wlan.py b/tests/wipy/wlan/wlan.py index 49e2e4af6..dd85c8696 100644 --- a/tests/wipy/wlan/wlan.py +++ b/tests/wipy/wlan/wlan.py @@ -1,6 +1,6 @@ -''' +""" WLAN test for the CC3200 based boards. -''' +""" from network import WLAN import os @@ -8,8 +8,8 @@ import time import testconfig mch = os.uname().machine -if not 'LaunchPad' in mch and not 'WiPy' in mch: - raise Exception('Board not supported!') +if not "LaunchPad" in mch and not "WiPy" in mch: + raise Exception("Board not supported!") def wait_for_connection(wifi, timeout=10): @@ -17,9 +17,9 @@ def wait_for_connection(wifi, timeout=10): time.sleep(1) timeout -= 1 if wifi.isconnected(): - print('Connected') + print("Connected") else: - print('Connection failed!') + print("Connection failed!") wifi = WLAN(0, WLAN.STA) @@ -31,16 +31,16 @@ print(wifi.mode() == WLAN.AP) print(wifi.channel() == 1) print(wifi.auth() == None) print(wifi.antenna() == WLAN.INT_ANT) -wifi = WLAN(0, mode=WLAN.AP, ssid='test-wlan', auth=(WLAN.WPA, '123456abc'), channel=7) +wifi = WLAN(0, mode=WLAN.AP, ssid="test-wlan", auth=(WLAN.WPA, "123456abc"), channel=7) print(wifi.mode() == WLAN.AP) print(wifi.channel() == 7) -print(wifi.ssid() == 'test-wlan') -print(wifi.auth() == (WLAN.WPA, '123456abc')) +print(wifi.ssid() == "test-wlan") +print(wifi.auth() == (WLAN.WPA, "123456abc")) print(wifi.antenna() == WLAN.INT_ANT) wifi = WLAN(mode=WLAN.STA) print(wifi.mode() == WLAN.STA) -time.sleep(5) # this ensures a full network scan +time.sleep(5) # this ensures a full network scan scan_r = wifi.scan() print(len(scan_r) > 3) for net in scan_r: @@ -50,30 +50,30 @@ for net in scan_r: print(net.channel == None) print(net.sec == testconfig.wlan_auth[0]) print(net.rssi < 0) - print('Network found') + print("Network found") break wifi.mode(WLAN.STA) print(wifi.mode() == WLAN.STA) wifi.channel(7) print(wifi.channel() == 7) -wifi.ssid('t-wlan') -print(wifi.ssid() == 't-wlan') +wifi.ssid("t-wlan") +print(wifi.ssid() == "t-wlan") wifi.auth(None) print(wifi.auth() == None) -wifi.auth((WLAN.WEP, '11223344556677889900')) -print(wifi.auth() == (WLAN.WEP, '11223344556677889900')) +wifi.auth((WLAN.WEP, "11223344556677889900")) +print(wifi.auth() == (WLAN.WEP, "11223344556677889900")) wifi.antenna(WLAN.INT_ANT) print(wifi.antenna() == WLAN.INT_ANT) wifi.antenna(WLAN.EXT_ANT) print(wifi.antenna() == WLAN.EXT_ANT) -time.sleep(2) # this ensures a full network scan +time.sleep(2) # this ensures a full network scan scan_r = wifi.scan() print(len(scan_r) > 3) for net in scan_r: if net.ssid == testconfig.wlan_ssid: - print('Network found') + print("Network found") break wifi.antenna(WLAN.INT_ANT) @@ -82,12 +82,12 @@ print(wifi.mode() == WLAN.STA) wifi.connect(testconfig.wlan_ssid, auth=testconfig.wlan_auth, timeout=10000) wait_for_connection(wifi) -wifi.ifconfig(config='dhcp') +wifi.ifconfig(config="dhcp") wait_for_connection(wifi) -print('0.0.0.0' not in wifi.ifconfig()) -wifi.ifconfig(0, ('192.168.178.109', '255.255.255.0', '192.168.178.1', '8.8.8.8')) +print("0.0.0.0" not in wifi.ifconfig()) +wifi.ifconfig(0, ("192.168.178.109", "255.255.255.0", "192.168.178.1", "8.8.8.8")) wait_for_connection(wifi) -print(wifi.ifconfig(0) == ('192.168.178.109', '255.255.255.0', '192.168.178.1', '8.8.8.8')) +print(wifi.ifconfig(0) == ("192.168.178.109", "255.255.255.0", "192.168.178.1", "8.8.8.8")) wait_for_connection(wifi) print(wifi.isconnected() == True) @@ -102,7 +102,7 @@ wifi.disconnect() print(wifi.isconnected() == False) # test init again -wifi.init(WLAN.AP, ssid='www.wipy.io', auth=None, channel=5, antenna=WLAN.INT_ANT) +wifi.init(WLAN.AP, ssid="www.wipy.io", auth=None, channel=5, antenna=WLAN.INT_ANT) print(wifi.mode() == WLAN.AP) # get the current instance without re-init @@ -118,65 +118,66 @@ print(len(wifi.mac()) == 6) try: wifi.init(mode=12345) except: - print('Exception') + print("Exception") try: wifi.init(1, mode=WLAN.AP) except: - print('Exception') + print("Exception") try: wifi.init(mode=WLAN.AP, ssid=None) except: - print('Exception') + print("Exception") try: wifi = WLAN(mode=WLAN.AP, channel=12) except: - print('Exception') + print("Exception") try: wifi.antenna(2) except: - print('Exception') + print("Exception") try: wifi.mode(10) except: - print('Exception') + print("Exception") try: - wifi.ssid('11111sdfasdfasdfasdf564sdf654asdfasdf123451245ssdgfsdf1111111111111111111111111234123412341234asdfasdf') + wifi.ssid( + "11111sdfasdfasdfasdf564sdf654asdfasdf123451245ssdgfsdf1111111111111111111111111234123412341234asdfasdf" + ) except: - print('Exception') + print("Exception") try: wifi.auth((0)) except: - print('Exception') + print("Exception") try: wifi.auth((0, None)) except: - print('Exception') + print("Exception") try: wifi.auth((10, 10)) except: - print('Exception') + print("Exception") try: wifi.channel(0) except: - print('Exception') + print("Exception") try: - wifi.ifconfig(1, 'dhcp') + wifi.ifconfig(1, "dhcp") except: - print('Exception') + print("Exception") try: wifi.ifconfig(config=()) except: - print('Exception') - + print("Exception") |