diff --git a/Lib/nntplib.py b/Lib/nntplib.py index 4ded78a9e87..d33faf85b9e 100644 --- a/Lib/nntplib.py +++ b/Lib/nntplib.py @@ -80,8 +80,8 @@ from email.header import decode_header as _email_decode_header from socket import _GLOBAL_DEFAULT_TIMEOUT __all__ = ["NNTP", - "NNTPReplyError", "NNTPTemporaryError", "NNTPPermanentError", - "NNTPProtocolError", "NNTPDataError", + "NNTPError", "NNTPReplyError", "NNTPTemporaryError", + "NNTPPermanentError", "NNTPProtocolError", "NNTPDataError", "decode_header", ] diff --git a/Lib/test/test_nntplib.py b/Lib/test/test_nntplib.py index 71a4ec022b1..fb216c1f52c 100644 --- a/Lib/test/test_nntplib.py +++ b/Lib/test/test_nntplib.py @@ -1412,11 +1412,18 @@ class MiscTests(unittest.TestCase): def test_ssl_support(self): self.assertTrue(hasattr(nntplib, 'NNTP_SSL')) -def test_main(): - tests = [MiscTests, NNTPv1Tests, NNTPv2Tests, CapsAfterLoginNNTPv2Tests, - SendReaderNNTPv2Tests, NetworkedNNTPTests, NetworkedNNTP_SSLTests] - support.run_unittest(*tests) +class PublicAPITests(unittest.TestCase): + """Ensures that the correct values are exposed in the public API.""" + + def test_module_all_attribute(self): + self.assertTrue(hasattr(nntplib, '__all__')) + target_api = ['NNTP', 'NNTPError', 'NNTPReplyError', + 'NNTPTemporaryError', 'NNTPPermanentError', + 'NNTPProtocolError', 'NNTPDataError', 'decode_header'] + if ssl is not None: + target_api.append('NNTP_SSL') + self.assertEqual(set(nntplib.__all__), set(target_api)) if __name__ == "__main__": - test_main() + unittest.main() diff --git a/Misc/NEWS b/Misc/NEWS index 83e0dbd8afa..1a02975986d 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -137,6 +137,8 @@ Core and Builtins Library ------- +- Issue #22247: Add NNTPError to nntplib.__all__. + - Issue #22366: urllib.request.urlopen will accept a context object (SSLContext) as an argument which will then used be for HTTPS connection. Patch by Alex Gaynor.