@@ -91,28 +91,26 @@ def test_ipaddr_info(self):
91
91
self .assertIsNone (
92
92
base_events ._ipaddr_info ('1.2.3.4' , 1 , UNSPEC , 0 , 0 ))
93
93
94
- if not support .IPV6_ENABLED :
95
- return
94
+ if support .IPV6_ENABLED :
95
+ # IPv4 address with family IPv6.
96
+ self .assertIsNone (
97
+ base_events ._ipaddr_info ('1.2.3.4' , 1 , INET6 , STREAM , TCP ))
96
98
97
- # IPv4 address with family IPv6.
98
- self .assertIsNone (
99
- base_events ._ipaddr_info ('1.2.3.4' , 1 , INET6 , STREAM , TCP ))
100
-
101
- self .assertEqual (
102
- (INET6 , STREAM , TCP , '' , ('::3' , 1 , 0 , 0 )),
103
- base_events ._ipaddr_info ('::3' , 1 , INET6 , STREAM , TCP ))
99
+ self .assertEqual (
100
+ (INET6 , STREAM , TCP , '' , ('::3' , 1 , 0 , 0 )),
101
+ base_events ._ipaddr_info ('::3' , 1 , INET6 , STREAM , TCP ))
104
102
105
- self .assertEqual (
106
- (INET6 , STREAM , TCP , '' , ('::3' , 1 , 0 , 0 )),
107
- base_events ._ipaddr_info ('::3' , 1 , UNSPEC , STREAM , TCP ))
103
+ self .assertEqual (
104
+ (INET6 , STREAM , TCP , '' , ('::3' , 1 , 0 , 0 )),
105
+ base_events ._ipaddr_info ('::3' , 1 , UNSPEC , STREAM , TCP ))
108
106
109
- # IPv6 address with family IPv4.
110
- self .assertIsNone (
111
- base_events ._ipaddr_info ('::3' , 1 , INET , STREAM , TCP ))
107
+ # IPv6 address with family IPv4.
108
+ self .assertIsNone (
109
+ base_events ._ipaddr_info ('::3' , 1 , INET , STREAM , TCP ))
112
110
113
- # IPv6 address with zone index.
114
- self .assertIsNone (
115
- base_events ._ipaddr_info ('::3%lo0' , 1 , INET6 , STREAM , TCP ))
111
+ # IPv6 address with zone index.
112
+ self .assertIsNone (
113
+ base_events ._ipaddr_info ('::3%lo0' , 1 , INET6 , STREAM , TCP ))
116
114
117
115
def test_port_parameter_types (self ):
118
116
# Test obscure kinds of arguments for "port".
@@ -1284,25 +1282,24 @@ def _test_create_connection_ip_addr(self, m_socket, allow_inet_pton):
1284
1282
t .close ()
1285
1283
test_utils .run_briefly (self .loop ) # allow transport to close
1286
1284
1287
- if not support .IPV6_ENABLED :
1288
- return
1289
-
1290
- sock .family = socket .AF_INET6
1291
- coro = self .loop .create_connection (asyncio .Protocol , '::1' , 80 )
1292
- t , p = self .loop .run_until_complete (coro )
1293
- try :
1294
- # Without inet_pton we use getaddrinfo, which transforms ('::1', 80)
1295
- # to ('::1', 80, 0, 0). The last 0s are flow info, scope id.
1296
- [address ] = sock .connect .call_args [0 ]
1297
- host , port = address [:2 ]
1298
- self .assertRegex (host , r'::(0\.)*1' )
1299
- self .assertEqual (port , 80 )
1300
- _ , kwargs = m_socket .socket .call_args
1301
- self .assertEqual (kwargs ['family' ], m_socket .AF_INET6 )
1302
- self .assertEqual (kwargs ['type' ], m_socket .SOCK_STREAM )
1303
- finally :
1304
- t .close ()
1305
- test_utils .run_briefly (self .loop ) # allow transport to close
1285
+ if support .IPV6_ENABLED :
1286
+ sock .family = socket .AF_INET6
1287
+ coro = self .loop .create_connection (asyncio .Protocol , '::1' , 80 )
1288
+ t , p = self .loop .run_until_complete (coro )
1289
+ try :
1290
+ # Without inet_pton we use getaddrinfo, which transforms
1291
+ # ('::1', 80) to ('::1', 80, 0, 0). The last 0s are flow info,
1292
+ # scope id.
1293
+ [address ] = sock .connect .call_args [0 ]
1294
+ host , port = address [:2 ]
1295
+ self .assertRegex (host , r'::(0\.)*1' )
1296
+ self .assertEqual (port , 80 )
1297
+ _ , kwargs = m_socket .socket .call_args
1298
+ self .assertEqual (kwargs ['family' ], m_socket .AF_INET6 )
1299
+ self .assertEqual (kwargs ['type' ], m_socket .SOCK_STREAM )
1300
+ finally :
1301
+ t .close ()
1302
+ test_utils .run_briefly (self .loop ) # allow transport to close
1306
1303
1307
1304
@unittest .skipUnless (support .IPV6_ENABLED , 'no IPv6 support' )
1308
1305
@unittest .skipIf (sys .platform .startswith ('aix' ),
0 commit comments