blob: e26060ad212a6c395dfdc064678f46c95e10c1a1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
import socket, sys
def test_non_existent():
try:
res = socket.getaddrinfo("nonexistent.example.com", 80)
print("getaddrinfo returned", res)
except OSError as e:
print("getaddrinfo raised")
def test_bogus():
try:
res = socket.getaddrinfo("hey.!!$$", 80)
print("getaddrinfo returned", res)
except OSError as e:
print("getaddrinfo raised")
except Exception as e:
print("getaddrinfo raised") # CPython raises UnicodeError!?
def test_ip_addr():
try:
res = socket.getaddrinfo("10.10.10.10", 80)
print("getaddrinfo returned resolutions")
except Exception as e:
print("getaddrinfo raised", e)
def test_0_0_0_0():
try:
res = socket.getaddrinfo("0.0.0.0", 80)
print("getaddrinfo returned resolutions")
except Exception as e:
print("getaddrinfo raised", e)
def test_valid():
try:
res = socket.getaddrinfo("micropython.org", 80)
print("getaddrinfo returned resolutions")
except Exception as e:
print("getaddrinfo raised", e)
test_funs = [n for n in dir() if n.startswith("test_")]
for f in sorted(test_funs):
print("--", f, end=": ")
eval(f + "()")
|