@@ -180,10 +180,16 @@ def test_errors(self):
180180 s = ssl .wrap_socket (sock , server_side = True , certfile = CERTFILE )
181181 self .assertRaisesRegexp (ValueError , "can't connect in server-side mode" ,
182182 s .connect , (HOST , 8080 ))
183- with self .assertRaisesRegexp (IOError , "No such file" ):
184- ssl .wrap_socket (sock , certfile = WRONGCERT )
185- ssl .wrap_socket (sock , keyfile = WRONGCERT )
186- ssl .wrap_socket (sock , certfile = WRONGCERT , keyfile = WRONGCERT )
183+ with self .assertRaises (IOError ) as err :
184+ ssl .wrap_socket (socket .socket (), certfile = WRONGCERT )
185+ self .assertEqual (err .errno , errno .ENOENT )
186+ # XXX - temporarily disabled as per issue #9711
187+ #with self.assertRaises(IOError) as err:
188+ # ssl.wrap_socket(socket.socket(), keyfile=WRONGCERT)
189+ # self.assertEqual(err.errno, errno.ENOENT)
190+ with self .assertRaises (IOError ) as err :
191+ ssl .wrap_socket (socket .socket (), certfile = WRONGCERT , keyfile = WRONGCERT )
192+ self .assertEqual (err .errno , errno .ENOENT )
187193
188194
189195class ContextTests (unittest .TestCase ):
@@ -253,8 +259,9 @@ def test_load_cert_chain(self):
253259 ctx .load_cert_chain (CERTFILE )
254260 ctx .load_cert_chain (CERTFILE , keyfile = CERTFILE )
255261 self .assertRaises (TypeError , ctx .load_cert_chain , keyfile = CERTFILE )
256- with self .assertRaisesRegexp (IOError , "No such file" ) :
262+ with self .assertRaises (IOError ) as err :
257263 ctx .load_cert_chain (WRONGCERT )
264+ self .assertEqual (err .errno , errno .ENOENT )
258265 with self .assertRaisesRegexp (ssl .SSLError , "PEM lib" ):
259266 ctx .load_cert_chain (BADCERT )
260267 with self .assertRaisesRegexp (ssl .SSLError , "PEM lib" ):
@@ -283,8 +290,9 @@ def test_load_verify_locations(self):
283290 ctx .load_verify_locations (cafile = BYTES_CERTFILE , capath = None )
284291 self .assertRaises (TypeError , ctx .load_verify_locations )
285292 self .assertRaises (TypeError , ctx .load_verify_locations , None , None )
286- with self .assertRaisesRegexp (IOError , "No such file" ) :
293+ with self .assertRaises (IOError ) as err :
287294 ctx .load_verify_locations (WRONGCERT )
295+ self .assertEqual (err .errno , errno .ENOENT )
288296 with self .assertRaisesRegexp (ssl .SSLError , "PEM lib" ):
289297 ctx .load_verify_locations (BADCERT )
290298 ctx .load_verify_locations (CERTFILE , CAPATH )
@@ -877,8 +885,10 @@ def bad_cert_test(certfile):
877885 if support .verbose :
878886 sys .stdout .write ("\n socket.error is %s\n " % x [1 ])
879887 except IOError as x :
888+ if x .errno != errno .ENOENT :
889+ raise
880890 if support .verbose :
881- sys .stdout .write ("\n socket.error is %s\n " % str (x ))
891+ sys .stdout .write ("\IOError is %s\n " % str (x ))
882892 else :
883893 raise AssertionError ("Use of invalid cert should have failed!" )
884894 finally :
0 commit comments