From 14ad5319d94901f6a74169f448badcf67f37c6ab Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Fri, 22 Aug 2014 10:44:47 -0400 Subject: Issue #22191: Fix warnings.__all__. Thanks to Jon Poler for the patch. --- Lib/test/test_warnings.py | 19 +++++++++++++++++++ Lib/warnings.py | 3 ++- Misc/ACKS | 1 + Misc/NEWS | 2 ++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py index eec2c24..43b3b9c 100644 --- a/Lib/test/test_warnings.py +++ b/Lib/test/test_warnings.py @@ -61,6 +61,25 @@ class BaseTest: 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(BaseTest): diff --git a/Lib/warnings.py b/Lib/warnings.py index a427e35..eeeba65 100644 --- a/Lib/warnings.py +++ b/Lib/warnings.py @@ -2,7 +2,8 @@ import sys -__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 b16dd70..4986dc6 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1054,6 +1054,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 9c4f560..9396ac9 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -27,6 +27,8 @@ Core and Builtins Library ------- +-- Issue #22191: Fix warnings.__all__. + - Issue #15696: Add a __sizeof__ implementation for mmap objects on Windows. - Issue #22068: Avoided reference loops with Variables and Fonts in Tkinter. -- cgit v0.12