Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8c9bba0

Browse files
committed
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.
1 parent 13e41c5 commit 8c9bba0

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

Lib/test/test_nntplib.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,15 +1509,16 @@ def handle_AUTHINFO(self, *args):
15091509
Handler, nntplib.NNTPPermanentError, authinfo_response,
15101510
login, password)
15111511

1512-
@unittest.skipUnless(ssl, 'requires SSL support')
1513-
class MockSslTests(MockSocketTests):
1514-
class nntp_class(nntplib.NNTP_SSL):
1515-
def __init__(self, *pos, **kw):
1516-
class bypass_context:
1517-
"""Bypass encryption and actual SSL module"""
1518-
def wrap_socket(sock, **args):
1519-
return sock
1520-
return super().__init__(*pos, ssl_context=bypass_context, **kw)
1512+
if ssl is not None:
1513+
class MockSslTests(MockSocketTests):
1514+
class nntp_class(nntplib.NNTP_SSL):
1515+
def __init__(self, *pos, **kw):
1516+
class bypass_context:
1517+
"""Bypass encryption and actual SSL module"""
1518+
def wrap_socket(sock, **args):
1519+
return sock
1520+
return super().__init__(*pos, ssl_context=bypass_context, **kw)
1521+
15211522

15221523
if __name__ == "__main__":
15231524
unittest.main()

0 commit comments

Comments
 (0)