From 01408453f12a1acd7c1b2caeca377d4bd6ea7947 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Fri, 22 Aug 2014 10:50:47 -0400 Subject: [PATCH] Issue #22191: Fix warnings.__all__. Thanks to Jon Poler for the patch. --- Lib/test/test___all__.py | 2 +- Lib/test/test_warnings.py | 19 +++++++++++++++++++ Lib/warnings.py | 3 ++- Misc/ACKS | 1 + Misc/NEWS | 2 ++ 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Lib/test/test___all__.py b/Lib/test/test___all__.py index 2c5dbefb3a..789f9fbf24 100644 --- a/Lib/test/test___all__.py +++ b/Lib/test/test___all__.py @@ -73,7 +73,7 @@ class AllTest(unittest.TestCase): # than an AttributeError somewhere deep in CGIHTTPServer. import _socket - # rlcompleter needs special consideration; it import readline which + # rlcompleter needs special consideration; it imports readline which # initializes GNU readline which calls setlocale(LC_CTYPE, "")... :-( try: import rlcompleter diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py index a770ba20f5..fb2046e99c 100644 --- a/Lib/test/test_warnings.py +++ b/Lib/test/test_warnings.py @@ -62,6 +62,25 @@ class BaseTest(unittest.TestCase): sys.modules['warnings'] = original_warnings super(BaseTest, self).tearDown() +class PublicAPITests(BaseTest): + + """Ensures that the correct values are exposed in the + public API. + """ + + def test_module_all_attribute(self): + self.assertTrue(hasattr(self.module, '__all__')) + target_api = ["warn", "warn_explicit", "showwarning", + "formatwarning", "filterwarnings", "simplefilter", + "resetwarnings", "catch_warnings"] + self.assertSetEqual(set(self.module.__all__), + set(target_api)) + +class CPublicAPITests(PublicAPITests, unittest.TestCase): + module = c_warnings + +class PyPublicAPITests(PublicAPITests, unittest.TestCase): + module = py_warnings class FilterTests(object): diff --git a/Lib/warnings.py b/Lib/warnings.py index 08b70afbad..bf9a5d86e1 100644 --- a/Lib/warnings.py +++ b/Lib/warnings.py @@ -7,7 +7,8 @@ import linecache import sys import types -__all__ = ["warn", "showwarning", "formatwarning", "filterwarnings", +__all__ = ["warn", "warn_explicit", "showwarning", + "formatwarning", "filterwarnings", "simplefilter", "resetwarnings", "catch_warnings"] diff --git a/Misc/ACKS b/Misc/ACKS index 4ebe074824..f9a4426b99 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1052,6 +1052,7 @@ Antoine Pitrou Jean-François Piéronne Oleg Plakhotnyuk Remi Pointel +Jon Poler Ariel Poliak Guilherme Polo Illia Polosukhin diff --git a/Misc/NEWS b/Misc/NEWS index 47ea776516..cbe93b11e3 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -19,6 +19,8 @@ Core and Builtins Library ------- +- Issue #22191: Fixed warnings.__all__. + - Issue #21308: Backport numerous features from Python's ssl module. This is part of PEP 466. -- 2.50.1