From 99dd9d93bfe5d6cdcdf778768f472d0c6884ff5d Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 3 Apr 2017 16:39:44 +0200 Subject: [PATCH] test_ssl: use API version to test get_ciphers() On AIX, ssl.SSLContext.get_ciphers() is not available, whereas ssl.OPENSSL_VERSION_INFO is (1, 0, 2, 8, 15). Display also the ssl API version when running test_ssl in verbose mode. --- Lib/test/test_ssl.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py index 69a65d20a4d8e79..14b19a6cd71932c 100644 --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -877,7 +877,8 @@ def test_ciphers(self): with self.assertRaisesRegex(ssl.SSLError, "No cipher can be selected"): ctx.set_ciphers("^$:,;?*'dorothyx") - @unittest.skipIf(ssl.OPENSSL_VERSION_INFO < (1, 0, 2, 0, 0), 'OpenSSL too old') + @unittest.skipIf(ssl._OPENSSL_API_VERSION < (1, 0, 2, 0, 0), + 'OpenSSL too old') def test_get_ciphers(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.set_ciphers('AESGCM') @@ -3595,8 +3596,11 @@ def test_main(verbose=False): break else: plat = repr(platform.platform()) - print("test_ssl: testing with %r %r" % - (ssl.OPENSSL_VERSION, ssl.OPENSSL_VERSION_INFO)) + print("test_ssl: testing with %r %r" + % (ssl.OPENSSL_VERSION, ssl.OPENSSL_VERSION_INFO)) + # ssl._OPENSSL_API_VERSION is a CPython implementation detail + if hasattr(ssl, '_OPENSSL_API_VERSION'): + print(f" API version {ssl._OPENSSL_API_VERSION}") print(" under %s" % plat) print(" HAS_SNI = %r" % ssl.HAS_SNI) print(" OP_ALL = 0x%8x" % ssl.OP_ALL)