Skip to content

Commit bc7659e

Browse files
committed
tests/connect_nonblock: Refactor towards real net_hosted test.
In the future, a special runner for such tests will import each test and call test() function with an address of test server to use.
1 parent 3f9d59c commit bc7659e

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

Diff for: tests/net_hosted/connect_nonblock.py

+13-7
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,16 @@
55
except:
66
import socket
77

8-
s = socket.socket()
9-
s.setblocking(False)
10-
try:
11-
s.connect(socket.getaddrinfo('micropython.org', 80)[0][-1])
12-
except OSError as er:
13-
print(er.args[0] == 115) # 115 is EINPROGRESS
14-
s.close()
8+
9+
def test(peer_addr):
10+
s = socket.socket()
11+
s.setblocking(False)
12+
try:
13+
s.connect(peer_addr)
14+
except OSError as er:
15+
print(er.args[0] == 115) # 115 is EINPROGRESS
16+
s.close()
17+
18+
19+
if __name__ == "__main__":
20+
test(socket.getaddrinfo('micropython.org', 80)[0][-1])

0 commit comments

Comments
 (0)