@@ -1109,6 +1109,15 @@ def _socket(*args, **kw):
11091109
11101110 self .assertEqual (str (cm .exception ), 'Multiple exceptions: err1, err2' )
11111111
1112+ idx = - 1
1113+ coro = self .loop .create_connection (MyProto , 'example.com' , 80 , all_errors = True )
1114+ with self .assertRaises (ExceptionGroup ) as cm :
1115+ self .loop .run_until_complete (coro )
1116+
1117+ self .assertIsInstance (cm .exception , ExceptionGroup )
1118+ for e in cm .exception .exceptions :
1119+ self .assertIsInstance (e , OSError )
1120+
11121121 @patch_socket
11131122 def test_create_connection_timeout (self , m_socket ):
11141123 # Ensure that the socket is closed on timeout
@@ -1228,6 +1237,14 @@ def getaddrinfo_task(*args, **kwds):
12281237 self .assertRaises (
12291238 OSError , self .loop .run_until_complete , coro )
12301239
1240+ coro = self .loop .create_connection (MyProto , 'example.com' , 80 , all_errors = True )
1241+ with self .assertRaises (ExceptionGroup ) as cm :
1242+ self .loop .run_until_complete (coro )
1243+
1244+ self .assertIsInstance (cm .exception , ExceptionGroup )
1245+ self .assertEqual (len (cm .exception .exceptions ), 1 )
1246+ self .assertIsInstance (cm .exception .exceptions [0 ], OSError )
1247+
12311248 def test_create_connection_multiple (self ):
12321249 async def getaddrinfo (* args , ** kw ):
12331250 return [(2 , 1 , 6 , '' , ('0.0.0.1' , 80 )),
@@ -1245,6 +1262,15 @@ def getaddrinfo_task(*args, **kwds):
12451262 with self .assertRaises (OSError ):
12461263 self .loop .run_until_complete (coro )
12471264
1265+ coro = self .loop .create_connection (
1266+ MyProto , 'example.com' , 80 , family = socket .AF_INET , all_errors = True )
1267+ with self .assertRaises (ExceptionGroup ) as cm :
1268+ self .loop .run_until_complete (coro )
1269+
1270+ self .assertIsInstance (cm .exception , ExceptionGroup )
1271+ for e in cm .exception .exceptions :
1272+ self .assertIsInstance (e , OSError )
1273+
12481274 @patch_socket
12491275 def test_create_connection_multiple_errors_local_addr (self , m_socket ):
12501276
@@ -1276,6 +1302,16 @@ def getaddrinfo_task(*args, **kwds):
12761302 self .assertTrue (str (cm .exception ).startswith ('Multiple exceptions: ' ))
12771303 self .assertTrue (m_socket .socket .return_value .close .called )
12781304
1305+ coro = self .loop .create_connection (
1306+ MyProto , 'example.com' , 80 , family = socket .AF_INET ,
1307+ local_addr = (None , 8080 ), all_errors = True )
1308+ with self .assertRaises (ExceptionGroup ) as cm :
1309+ self .loop .run_until_complete (coro )
1310+
1311+ self .assertIsInstance (cm .exception , ExceptionGroup )
1312+ for e in cm .exception .exceptions :
1313+ self .assertIsInstance (e , OSError )
1314+
12791315 def _test_create_connection_ip_addr (self , m_socket , allow_inet_pton ):
12801316 # Test the fallback code, even if this system has inet_pton.
12811317 if not allow_inet_pton :
0 commit comments