Skip to content
This repository was archived by the owner on Nov 23, 2017. It is now read-only.

Commit 2b7d276

Browse files
committed
Removed the test_utils module from the examples.
This fixes issue #470
1 parent a5df171 commit 2b7d276

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

examples/cacheclt.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import argparse
77
import asyncio
8-
import asyncio.test_utils
98
import json
109
import logging
1110

@@ -173,7 +172,12 @@ def main():
173172
loop = asyncio.new_event_loop()
174173
sslctx = None
175174
if args.tls:
176-
sslctx = test_utils.dummy_ssl_context()
175+
try:
176+
import ssl
177+
except ImportError as exc:
178+
logging.info('SSL not available: %r' % exc)
179+
else:
180+
sslctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
177181
cache = CacheClient(args.host, args.port, sslctx=sslctx, loop=loop)
178182
try:
179183
loop.run_until_complete(

examples/source.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import argparse
44
import asyncio
5-
import asyncio.test_utils
65
import sys
76

87

@@ -72,7 +71,12 @@ def connection_lost(self, exc):
7271
def start(loop, host, port):
7372
sslctx = None
7473
if args.tls:
75-
sslctx = test_utils.dummy_ssl_context()
74+
try:
75+
import ssl
76+
except ImportError as exc:
77+
print('SSL not available: %r' % exc)
78+
else:
79+
sslctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
7680
tr, pr = yield from loop.create_connection(Client, host, port,
7781
ssl=sslctx)
7882
dprint('tr =', tr)

examples/source1.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import argparse
44
import asyncio
5-
import asyncio.test_utils
65
import sys
76

87

@@ -54,9 +53,14 @@ def start(loop, args):
5453
d = Debug()
5554
total = 0
5655
sslctx = None
57-
if args.tls:
58-
d.print('using dummy SSLContext')
59-
sslctx = test_utils.dummy_ssl_context()
56+
if args.tls:
57+
try:
58+
import ssl
59+
except ImportError as exc:
60+
print('SSL not available: %r' % exc)
61+
else:
62+
d.print('using dummy SSLContext')
63+
sslctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
6064
r, w = yield from asyncio.open_connection(args.host, args.port, ssl=sslctx)
6165
d.print('r =', r)
6266
d.print('w =', w)

0 commit comments

Comments
 (0)