diff options
author | Giampaolo RodolĂ <g.rodola@gmail.com> | 2010-08-29 20:56:56 (GMT) |
---|---|---|
committer | Giampaolo RodolĂ <g.rodola@gmail.com> | 2010-08-29 20:56:56 (GMT) |
commit | cd9dfb919aaddda3e10ae92232a10aaa28dcfba0 (patch) | |
tree | c929db3f51a09931e30ad4f528e53b3bece17433 /Lib/test | |
parent | 51078b1e5d6795ba42a65c87d2d1e0ea9b9ef458 (diff) | |
download | cpython-cd9dfb919aaddda3e10ae92232a10aaa28dcfba0.zip cpython-cd9dfb919aaddda3e10ae92232a10aaa28dcfba0.tar.gz cpython-cd9dfb919aaddda3e10ae92232a10aaa28dcfba0.tar.bz2 |
in ssl tests rely on IOError.errno rather thanf IOError.strerror for better compatibility across platforms.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_ssl.py | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py index b485605..b96c868 100644 --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -180,10 +180,16 @@ class BasicSocketTests(unittest.TestCase): s = ssl.wrap_socket(sock, server_side=True, certfile=CERTFILE) self.assertRaisesRegexp(ValueError, "can't connect in server-side mode", s.connect, (HOST, 8080)) - with self.assertRaisesRegexp(IOError, "No such file"): - ssl.wrap_socket(sock, certfile=WRONGCERT) - ssl.wrap_socket(sock, keyfile=WRONGCERT) - ssl.wrap_socket(sock, certfile=WRONGCERT, keyfile=WRONGCERT) + with self.assertRaises(IOError) as err: + ssl.wrap_socket(socket.socket(), certfile=WRONGCERT) + self.assertEqual(err.errno, errno.ENOENT) + # XXX - temporarily disabled as per issue #9711 + #with self.assertRaises(IOError) as err: + # ssl.wrap_socket(socket.socket(), keyfile=WRONGCERT) + # self.assertEqual(err.errno, errno.ENOENT) + with self.assertRaises(IOError) as err: + ssl.wrap_socket(socket.socket(), certfile=WRONGCERT, keyfile=WRONGCERT) + self.assertEqual(err.errno, errno.ENOENT) class ContextTests(unittest.TestCase): @@ -253,8 +259,9 @@ class ContextTests(unittest.TestCase): ctx.load_cert_chain(CERTFILE) ctx.load_cert_chain(CERTFILE, keyfile=CERTFILE) self.assertRaises(TypeError, ctx.load_cert_chain, keyfile=CERTFILE) - with self.assertRaisesRegexp(IOError, "No such file"): + with self.assertRaises(IOError) as err: ctx.load_cert_chain(WRONGCERT) + self.assertEqual(err.errno, errno.ENOENT) with self.assertRaisesRegexp(ssl.SSLError, "PEM lib"): ctx.load_cert_chain(BADCERT) with self.assertRaisesRegexp(ssl.SSLError, "PEM lib"): @@ -283,8 +290,9 @@ class ContextTests(unittest.TestCase): ctx.load_verify_locations(cafile=BYTES_CERTFILE, capath=None) self.assertRaises(TypeError, ctx.load_verify_locations) self.assertRaises(TypeError, ctx.load_verify_locations, None, None) - with self.assertRaisesRegexp(IOError, "No such file"): + with self.assertRaises(IOError) as err: ctx.load_verify_locations(WRONGCERT) + self.assertEqual(err.errno, errno.ENOENT) with self.assertRaisesRegexp(ssl.SSLError, "PEM lib"): ctx.load_verify_locations(BADCERT) ctx.load_verify_locations(CERTFILE, CAPATH) @@ -877,8 +885,10 @@ else: if support.verbose: sys.stdout.write("\nsocket.error is %s\n" % x[1]) except IOError as x: + if x.errno != errno.ENOENT: + raise if support.verbose: - sys.stdout.write("\nsocket.error is %s\n" % str(x)) + sys.stdout.write("\IOError is %s\n" % str(x)) else: raise AssertionError("Use of invalid cert should have failed!") finally: |