@@ -146,6 +146,26 @@ def test_port_parameter_types(self):
146146 (INET , STREAM , TCP , '' , ('1.2.3.4' , 1 )),
147147 base_events ._ipaddr_info ('1.2.3.4' , b'1' , INET , STREAM , TCP ))
148148
149+ def test_getaddrinfo_servname (self ):
150+ INET = socket .AF_INET
151+ STREAM = socket .SOCK_STREAM
152+ TCP = socket .IPPROTO_TCP
153+
154+ self .assertEqual (
155+ (INET , STREAM , TCP , '' , ('1.2.3.4' , 80 )),
156+ base_events ._ipaddr_info ('1.2.3.4' , 'http' , INET , STREAM , TCP ))
157+
158+ self .assertEqual (
159+ (INET , STREAM , TCP , '' , ('1.2.3.4' , 80 )),
160+ base_events ._ipaddr_info ('1.2.3.4' , b'http' , INET , STREAM , TCP ))
161+
162+ # Raises "service/proto not found".
163+ with self .assertRaises (OSError ):
164+ base_events ._ipaddr_info ('1.2.3.4' , 'nonsense' , INET , STREAM , TCP )
165+
166+ with self .assertRaises (OSError ):
167+ base_events ._ipaddr_info ('1.2.3.4' , 'nonsense' , INET , STREAM , TCP )
168+
149169 @patch_socket
150170 def test_ipaddr_info_no_inet_pton (self , m_socket ):
151171 del m_socket .inet_pton
0 commit comments