mirror of https://github.com/python/cpython
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.
This commit is contained in:
parent
13e41c516a
commit
8c9bba07d4
|
@ -1509,15 +1509,16 @@ class MockSocketTests(unittest.TestCase):
|
||||||
Handler, nntplib.NNTPPermanentError, authinfo_response,
|
Handler, nntplib.NNTPPermanentError, authinfo_response,
|
||||||
login, password)
|
login, password)
|
||||||
|
|
||||||
@unittest.skipUnless(ssl, 'requires SSL support')
|
if ssl is not None:
|
||||||
class MockSslTests(MockSocketTests):
|
class MockSslTests(MockSocketTests):
|
||||||
class nntp_class(nntplib.NNTP_SSL):
|
class nntp_class(nntplib.NNTP_SSL):
|
||||||
def __init__(self, *pos, **kw):
|
def __init__(self, *pos, **kw):
|
||||||
class bypass_context:
|
class bypass_context:
|
||||||
"""Bypass encryption and actual SSL module"""
|
"""Bypass encryption and actual SSL module"""
|
||||||
def wrap_socket(sock, **args):
|
def wrap_socket(sock, **args):
|
||||||
return sock
|
return sock
|
||||||
return super().__init__(*pos, ssl_context=bypass_context, **kw)
|
return super().__init__(*pos, ssl_context=bypass_context, **kw)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in New Issue