[Python-checkins] cpython (3.4): Issue #22351: Fix test_nntplib if the ssl module is missing

victor.stinner python-checkins at python.org
Fri Apr 3 11:09:42 CEST 2015


https://hg.python.org/cpython/rev/c3e7a670dda2
changeset:   95406:c3e7a670dda2
branch:      3.4
parent:      95403:ca8666310eb3
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Fri Apr 03 11:06:40 2015 +0200
summary:
  Issue #22351: Fix test_nntplib if the ssl module is missing

@unittest.skipUnless(ssl, '...') doesn't work because the class body uses the
nntplib.NNTP_SSL attribute which doesn't exist.

files:
  Lib/test/test_nntplib.py |  19 ++++++++++---------
  1 files changed, 10 insertions(+), 9 deletions(-)


diff --git a/Lib/test/test_nntplib.py b/Lib/test/test_nntplib.py
--- a/Lib/test/test_nntplib.py
+++ b/Lib/test/test_nntplib.py
@@ -1509,15 +1509,16 @@
             Handler, nntplib.NNTPPermanentError, authinfo_response,
             login, password)
 
- at unittest.skipUnless(ssl, 'requires SSL support')
-class MockSslTests(MockSocketTests):
-    class nntp_class(nntplib.NNTP_SSL):
-        def __init__(self, *pos, **kw):
-            class bypass_context:
-                """Bypass encryption and actual SSL module"""
-                def wrap_socket(sock, **args):
-                    return sock
-            return super().__init__(*pos, ssl_context=bypass_context, **kw)
+if ssl is not None:
+    class MockSslTests(MockSocketTests):
+        class nntp_class(nntplib.NNTP_SSL):
+            def __init__(self, *pos, **kw):
+                class bypass_context:
+                    """Bypass encryption and actual SSL module"""
+                    def wrap_socket(sock, **args):
+                        return sock
+                return super().__init__(*pos, ssl_context=bypass_context, **kw)
+
 
 if __name__ == "__main__":
     unittest.main()

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list