try:import usocket as socket, sysexcept:import socket, sysdef 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 + "()")
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。