Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions Lib/asyncio/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@
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
Expand Down Expand Up @@ -114,12 +129,8 @@ def finish_request(self, request, client_address):
# 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)

Expand Down
73 changes: 0 additions & 73 deletions Lib/test/test_asyncio/keycert3.pem

This file was deleted.

78 changes: 0 additions & 78 deletions Lib/test/test_asyncio/pycacert.pem

This file was deleted.

15 changes: 0 additions & 15 deletions Lib/test/test_asyncio/ssl_cert.pem

This file was deleted.

16 changes: 0 additions & 16 deletions Lib/test/test_asyncio/ssl_key.pem

This file was deleted.

18 changes: 3 additions & 15 deletions Lib/test/test_asyncio/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,13 @@
from asyncio import selector_events
from asyncio import sslproto
from asyncio import test_utils
from asyncio.test_utils import ONLYKEY, ONLYCERT, data_file
try:
from test import support
except ImportError:
from asyncio import test_support as support


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(__file__), filename)
if os.path.isfile(fullname):
return fullname
raise FileNotFoundError(filename)


def osx_tiger():
"""Return True if the platform is Mac OS 10.4 or older."""
if sys.platform != 'darwin':
Expand All @@ -67,10 +57,8 @@ async def doit():
return loop.run_until_complete(doit())


ONLYCERT = data_file('ssl_cert.pem')
ONLYKEY = data_file('ssl_key.pem')
SIGNED_CERTFILE = data_file('keycert3.pem')
SIGNING_CA = data_file('pycacert.pem')
SIGNED_CERTFILE = test_utils.data_file('keycert3.pem')
SIGNING_CA = test_utils.data_file('pycacert.pem')
PEERCERT = {
'OCSP': ('http://testca.pythontest.net/testca/ocsp/',),
'caIssuers': ('http://testca.pythontest.net/testca/pycacert.cer',),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Modify test_asyncio to use the certificate set from the test directory.