summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorGuido van Rossum <guido@dropbox.com>2013-11-01 21:22:30 (GMT)
committerGuido van Rossum <guido@dropbox.com>2013-11-01 21:22:30 (GMT)
commit28dff0d8238aa8f34e7858209e598f1db8bfbf70 (patch)
tree94ccbc396c7c320e0b130f077d92603fce976029 /Lib/test
parenta8d630a6e6190a4873a16a6a8c02f561e1e1c7fe (diff)
downloadcpython-28dff0d8238aa8f34e7858209e598f1db8bfbf70.zip
cpython-28dff0d8238aa8f34e7858209e598f1db8bfbf70.tar.gz
cpython-28dff0d8238aa8f34e7858209e598f1db8bfbf70.tar.bz2
asyncio: Better-looking errors when ssl module cannot be imported. In part by Arnaud Faure.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_asyncio/test_selector_events.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_selector_events.py b/Lib/test/test_asyncio/test_selector_events.py
index 3b8238d..04a7d0c 100644
--- a/Lib/test/test_asyncio/test_selector_events.py
+++ b/Lib/test/test_asyncio/test_selector_events.py
@@ -43,6 +43,7 @@ class BaseSelectorEventLoopTests(unittest.TestCase):
self.assertIsInstance(
self.loop._make_socket_transport(m, m), _SelectorSocketTransport)
+ @unittest.skipIf(ssl is None, 'No ssl module')
def test_make_ssl_transport(self):
m = unittest.mock.Mock()
self.loop.add_reader = unittest.mock.Mock()
@@ -52,6 +53,16 @@ class BaseSelectorEventLoopTests(unittest.TestCase):
self.assertIsInstance(
self.loop._make_ssl_transport(m, m, m, m), _SelectorSslTransport)
+ @unittest.mock.patch('asyncio.selector_events.ssl', None)
+ def test_make_ssl_transport_without_ssl_error(self):
+ m = unittest.mock.Mock()
+ self.loop.add_reader = unittest.mock.Mock()
+ self.loop.add_writer = unittest.mock.Mock()
+ self.loop.remove_reader = unittest.mock.Mock()
+ self.loop.remove_writer = unittest.mock.Mock()
+ with self.assertRaises(RuntimeError):
+ self.loop._make_ssl_transport(m, m, m, m)
+
def test_close(self):
ssock = self.loop._ssock
ssock.fileno.return_value = 7
@@ -1277,6 +1288,15 @@ class SelectorSslTransportTests(unittest.TestCase):
server_hostname='localhost')
+class SelectorSslWithoutSslTransportTests(unittest.TestCase):
+
+ @unittest.mock.patch('asyncio.selector_events.ssl', None)
+ def test_ssl_transport_requires_ssl_module(self):
+ Mock = unittest.mock.Mock
+ with self.assertRaises(RuntimeError):
+ transport = _SelectorSslTransport(Mock(), Mock(), Mock(), Mock())
+
+
class SelectorDatagramTransportTests(unittest.TestCase):
def setUp(self):