tests: Use .errno instead of .args[0] for OSError exceptions.
Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
@@ -12,5 +12,5 @@ s.listen(1)
|
||||
try:
|
||||
s.accept()
|
||||
except OSError as er:
|
||||
print(er.args[0] == 11) # 11 is EAGAIN
|
||||
print(er.errno == 11) # 11 is EAGAIN
|
||||
s.close()
|
||||
|
||||
@@ -18,5 +18,5 @@ s.listen(1)
|
||||
try:
|
||||
s.accept()
|
||||
except OSError as er:
|
||||
print(er.args[0] in (errno.ETIMEDOUT, "timed out")) # CPython uses a string instead of errno
|
||||
print(er.errno in (errno.ETIMEDOUT, "timed out")) # CPython uses a string instead of errno
|
||||
s.close()
|
||||
|
||||
@@ -13,7 +13,7 @@ def test(peer_addr):
|
||||
try:
|
||||
s.connect(peer_addr)
|
||||
except OSError as er:
|
||||
print(er.args[0] == errno.EINPROGRESS)
|
||||
print(er.errno == errno.EINPROGRESS)
|
||||
s.close()
|
||||
|
||||
|
||||
|
||||
@@ -25,9 +25,9 @@ def do_connect(peer_addr, tls, handshake):
|
||||
# print("Connecting to", peer_addr)
|
||||
s.connect(peer_addr)
|
||||
except OSError as er:
|
||||
print("connect:", er.args[0] == errno.EINPROGRESS)
|
||||
if er.args[0] != errno.EINPROGRESS:
|
||||
print(" got", er.args[0])
|
||||
print("connect:", er.errno == errno.EINPROGRESS)
|
||||
if er.errno != errno.EINPROGRESS:
|
||||
print(" got", er.errno)
|
||||
# wrap with ssl/tls if desired
|
||||
if tls:
|
||||
try:
|
||||
@@ -67,7 +67,7 @@ def test(peer_addr, tls=False, handshake=False):
|
||||
except OSError as er:
|
||||
#
|
||||
dp(er)
|
||||
print("send:", er.args[0] in (errno.EAGAIN, errno.EINPROGRESS))
|
||||
print("send:", er.errno in (errno.EAGAIN, errno.EINPROGRESS))
|
||||
s.close()
|
||||
else: # fake it...
|
||||
print("connect:", True)
|
||||
@@ -103,7 +103,7 @@ def test(peer_addr, tls=False, handshake=False):
|
||||
print("recv:", s.recv(10))
|
||||
except OSError as er:
|
||||
dp(er)
|
||||
print("recv:", er.args[0] == errno.EAGAIN)
|
||||
print("recv:", er.errno == errno.EAGAIN)
|
||||
s.close()
|
||||
else: # fake it...
|
||||
print("connect:", True)
|
||||
|
||||
Reference in New Issue
Block a user