mirror of
https://github.com/micropython/micropython.git
synced 2026-06-11 00:55:15 +02:00
72222a63ca
Some socket implementations (eg `extmod/modsocket.c`) don't (and can't easily) raise an exception for an invalid socket type. So just test that passing such a value doesn't crash the device. Signed-off-by: Damien George <damien@micropython.org>
30 lines
596 B
Python
30 lines
596 B
Python
# Test passing in bad values to socket.socket constructor.
|
|
|
|
try:
|
|
import socket
|
|
except:
|
|
print("SKIP")
|
|
raise SystemExit
|
|
|
|
try:
|
|
s = socket.socket(None)
|
|
except TypeError:
|
|
print("TypeError")
|
|
|
|
try:
|
|
s = socket.socket(socket.AF_INET, None)
|
|
except TypeError:
|
|
print("TypeError")
|
|
|
|
# This may or may not raise an exception, depending on the socket implementation.
|
|
# The test is here for coverage.
|
|
try:
|
|
s = socket.socket(socket.AF_INET, 123456)
|
|
except OSError:
|
|
pass
|
|
|
|
try:
|
|
s = socket.socket(socket.AF_INET, socket.SOCK_RAW, None)
|
|
except TypeError:
|
|
print("TypeError")
|