diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-04-03 09:06:40 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-04-03 09:06:40 (GMT) |
commit | 8c9bba07d40f8a86bfa0dc87a4c06f91a07676a6 (patch) | |
tree | 35f2c02502c30918527f9f0723b32d34bd57eb6f /Lib/test/test_nntplib.py | |
parent | 13e41c516a2e7fc3f3bb298fb2b38b88075294a2 (diff) | |
download | cpython-8c9bba07d40f8a86bfa0dc87a4c06f91a07676a6.zip cpython-8c9bba07d40f8a86bfa0dc87a4c06f91a07676a6.tar.gz cpython-8c9bba07d40f8a86bfa0dc87a4c06f91a07676a6.tar.bz2 |
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.
Diffstat (limited to 'Lib/test/test_nntplib.py')
-rw-r--r-- | 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 index 9e88ddb..9a80674 100644 --- a/Lib/test/test_nntplib.py +++ b/Lib/test/test_nntplib.py @@ -1509,15 +1509,16 @@ class MockSocketTests(unittest.TestCase): Handler, nntplib.NNTPPermanentError, authinfo_response, login, password) -@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() |