From 02250e57c37339ea6de08ab077a307e75eef02f5 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 30 Nov 2018 20:44:43 +0100 Subject: bpo-35352: test_asyncio uses the certificate set from the test directory (GH-10826) (GH-10832) Modify asyncio tests to utilize the certificates from the test directory instead of its own set, as they are the same and with each update they had to be updated as well. (cherry picked from commit b062ba77b617b0f89b7ea25d14cc77c991462ad4) --- Lib/asyncio/test_utils.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'Lib/asyncio/test_utils.py') diff --git a/Lib/asyncio/test_utils.py b/Lib/asyncio/test_utils.py index f41720428c..116b3fcb3e 100644 --- a/Lib/asyncio/test_utils.py +++ b/Lib/asyncio/test_utils.py @@ -42,6 +42,21 @@ else: from socket import socketpair # pragma: no cover +def data_file(filename): + if hasattr(support, 'TEST_HOME_DIR'): + fullname = os.path.join(support.TEST_HOME_DIR, filename) + if os.path.isfile(fullname): + return fullname + fullname = os.path.join(os.path.dirname(os.__file__), 'test', filename) + if os.path.isfile(fullname): + return fullname + raise FileNotFoundError(filename) + + +ONLYCERT = data_file('ssl_cert.pem') +ONLYKEY = data_file('ssl_key.pem') + + def dummy_ssl_context(): if ssl is None: return None @@ -114,12 +129,8 @@ class SSLWSGIServerMixin: # contains the ssl key and certificate files) differs # between the stdlib and stand-alone asyncio. # Prefer our own if we can find it. - here = os.path.join(os.path.dirname(__file__), '..', 'tests') - if not os.path.isdir(here): - here = os.path.join(os.path.dirname(os.__file__), - 'test', 'test_asyncio') - keyfile = os.path.join(here, 'ssl_key.pem') - certfile = os.path.join(here, 'ssl_cert.pem') + keyfile = ONLYKEY + certfile = ONLYCERT context = ssl.SSLContext() context.load_cert_chain(certfile, keyfile) -- cgit v1.2.1