]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #22351. MockSslTests tests in test_nntplib now are reported if skipped.
authorSerhiy Storchaka <storchaka@gmail.com>
Fri, 3 Apr 2015 12:02:20 +0000 (15:02 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Fri, 3 Apr 2015 12:02:20 +0000 (15:02 +0300)
Lib/test/test_nntplib.py

index 9a8067434ced14a74cc61eb84e9ef0fe041752ea..ae3618ffbca75f057bde6257cbe15980ea8ef933 100644 (file)
@@ -1509,15 +1509,16 @@ class MockSocketTests(unittest.TestCase):
             Handler, nntplib.NNTPPermanentError, authinfo_response,
             login, password)
 
-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)
+class bypass_context:
+    """Bypass encryption and actual SSL module"""
+    def wrap_socket(sock, **args):
+        return sock
+
+@unittest.skipUnless(ssl, 'requires SSL support')
+class MockSslTests(MockSocketTests):
+    @staticmethod
+    def nntp_class(*pos, **kw):
+        return nntplib.NNTP_SSL(*pos, ssl_context=bypass_context, **kw)
 
 
 if __name__ == "__main__":