def test_hostname_unicode(self): import _socket domain = u"испытание.pythontest.net" _socket.gethostbyname(domain) _socket.gethostbyname_ex(domain) _socket.getaddrinfo(domain, 0, _socket.AF_UNSPEC, _socket.SOCK_STREAM) s = _socket.socket(_socket.AF_INET, _socket.SOCK_STREAM) s.connect((domain, 80)) s.close() raises(TypeError, s.connect, (domain + '\x00', 80))
def test_gethostbyname_ex(self): '''Tests _socket.gethostbyname_ex''' #sanity joe = _socket.gethostbyname_ex("localhost")[2] self.assertTrue("127.0.0.1" in joe) joe = _socket.gethostbyname_ex("127.0.0.1")[2] self.assertTrue("127.0.0.1" in joe) #negative self.assertRaises(_socket.gaierror, _socket.gethostbyname_ex, "should never work")
def test_gethostbyname_ex(self): '''Tests _socket.gethostbyname_ex''' #sanity joe = _socket.gethostbyname_ex("localhost")[2] self.assertIn("127.0.0.1", joe) joe = _socket.gethostbyname_ex("127.0.0.1")[2] self.assertIn("127.0.0.1", joe) #negative self.assertRaises(_socket.gaierror, _socket.gethostbyname_ex, "should never work")
def from_name(cls, name): """creates an Address instance from a host name""" try: official_name, aliases, addresses = _socket.gethostbyname_ex(name) except _socket.error, ex: raise AddressError(*ex.args)
def from_name(cls, name): """creates an Address instance from a host name""" try: official_name, aliases, addresses = _socket.gethostbyname_ex(name) except _socket.error, ex: raise AddressError(*ex.args)