summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/test_utils.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-11-30 19:44:43 (GMT)
committerGitHub <noreply@github.com>2018-11-30 19:44:43 (GMT)
commit02250e57c37339ea6de08ab077a307e75eef02f5 (patch)
treebe9f3f4a7770e43e26470b281488fcab7bb912fb /Lib/asyncio/test_utils.py
parent03b1200dfd03061e9ad0bff8199967bd80b9b900 (diff)
downloadcpython-02250e57c37339ea6de08ab077a307e75eef02f5.zip
cpython-02250e57c37339ea6de08ab077a307e75eef02f5.tar.gz
cpython-02250e57c37339ea6de08ab077a307e75eef02f5.tar.bz2
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)
Diffstat (limited to 'Lib/asyncio/test_utils.py')
-rw-r--r--Lib/asyncio/test_utils.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/Lib/asyncio/test_utils.py b/Lib/asyncio/test_utils.py
index f417204..116b3fc 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)