diff options
| author | Victor Stinner <victor.stinner@gmail.com> | 2014-11-20 13:16:31 (GMT) |
|---|---|---|
| committer | Victor Stinner <victor.stinner@gmail.com> | 2014-11-20 13:16:31 (GMT) |
| commit | 662fd5f68ef1a3bf7f4f7bbb4e50a876216424eb (patch) | |
| tree | f435bf8369e007243faa453565d226e3df643572 /Lib/test/test_asyncio/test_events.py | |
| parent | abde2c1d2511367c6199d6bb21ec63cecb7ac6b8 (diff) | |
| download | cpython-662fd5f68ef1a3bf7f4f7bbb4e50a876216424eb.zip cpython-662fd5f68ef1a3bf7f4f7bbb4e50a876216424eb.tar.gz cpython-662fd5f68ef1a3bf7f4f7bbb4e50a876216424eb.tar.bz2 | |
asyncio: Fix formatting of the "Future exception was never retrieved" in
release mode
Diffstat (limited to 'Lib/test/test_asyncio/test_events.py')
| -rw-r--r-- | Lib/test/test_asyncio/test_events.py | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py index 4fe4b4c..b05cb7c 100644 --- a/Lib/test/test_asyncio/test_events.py +++ b/Lib/test/test_asyncio/test_events.py @@ -606,27 +606,29 @@ class EventLoopTestsMixin: self.assertGreater(pr.nbytes, 0) tr.close() - if ssl: - def _dummy_ssl_create_context(self, purpose=ssl.Purpose.SERVER_AUTH, *, - cafile=None, capath=None, cadata=None): - """ - A ssl.create_default_context() replacement that doesn't enable - cert validation. - """ - self.assertEqual(purpose, ssl.Purpose.SERVER_AUTH) - return test_utils.dummy_ssl_context() - def _test_create_ssl_connection(self, httpd, create_connection, check_sockname=True): conn_fut = create_connection(ssl=test_utils.dummy_ssl_context()) self._basetest_create_ssl_connection(conn_fut, check_sockname) - # With ssl=True, ssl.create_default_context() should be called - with mock.patch('ssl.create_default_context', - side_effect=self._dummy_ssl_create_context) as m: - conn_fut = create_connection(ssl=True) - self._basetest_create_ssl_connection(conn_fut, check_sockname) - self.assertEqual(m.call_count, 1) + # ssl.Purpose was introduced in Python 3.4 + if hasattr(ssl, 'Purpose'): + def _dummy_ssl_create_context(purpose=ssl.Purpose.SERVER_AUTH, *, + cafile=None, capath=None, + cadata=None): + """ + A ssl.create_default_context() replacement that doesn't enable + cert validation. + """ + self.assertEqual(purpose, ssl.Purpose.SERVER_AUTH) + return test_utils.dummy_ssl_context() + + # With ssl=True, ssl.create_default_context() should be called + with mock.patch('ssl.create_default_context', + side_effect=_dummy_ssl_create_context) as m: + conn_fut = create_connection(ssl=True) + self._basetest_create_ssl_connection(conn_fut, check_sockname) + self.assertEqual(m.call_count, 1) # With the real ssl.create_default_context(), certificate # validation will fail |
