MCPcopy Index your code
hub / github.com/RustPython/RustPython / testHostnameRes

Method testHostnameRes

Lib/test/test_socket.py:1093–1110  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1091 self.assertHasAttr(socket, opt)
1092
1093 def testHostnameRes(self):
1094 # Testing hostname resolution mechanisms
1095 hostname = socket.gethostname()
1096 try:
1097 ip = socket.gethostbyname(hostname)
1098 except OSError:
1099 # Probably name lookup wasn't set up right; skip this test
1100 self.skipTest('name lookup failure')
1101 self.assertTrue(ip.find('.') >= 0, "Error resolving host to ip.")
1102 try:
1103 hname, aliases, ipaddrs = socket.gethostbyaddr(ip)
1104 except OSError:
1105 # Probably a similar problem as above; skip this test
1106 self.skipTest('name lookup failure')
1107 all_host_names = [hostname, hname] + aliases
1108 fqhn = socket.getfqdn(ip)
1109 if not fqhn in all_host_names:
1110 self.fail("Error testing host resolution mechanisms. (fqdn: %s, all: %s)" % (fqhn, repr(all_host_names)))
1111
1112 def test_host_resolution(self):
1113 for addr in [socket_helper.HOSTv4, '10.0.0.1', '255.255.255.255']:

Callers

nothing calls this directly

Calls 5

reprFunction · 0.85
skipTestMethod · 0.80
assertTrueMethod · 0.80
findMethod · 0.45
failMethod · 0.45

Tested by

no test coverage detected