]> granicus.if.org Git - python/commitdiff
Issue #22191: Fix warnings.__all__.
authorBrett Cannon <brett@python.org>
Fri, 22 Aug 2014 14:44:47 +0000 (10:44 -0400)
committerBrett Cannon <brett@python.org>
Fri, 22 Aug 2014 14:44:47 +0000 (10:44 -0400)
Thanks to Jon Poler for the patch.

Lib/test/test_warnings.py
Lib/warnings.py
Misc/ACKS
Misc/NEWS

index eec2c2421832bffc9705a3937a680af49b9b46dd..43b3b9c1287ae4de00ddf338fe6069af0b9b40f6 100644 (file)
@@ -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):
 
index a427e3510ecaaa6dadeb2a4e957bb6d4880576c7..eeeba6537410d7f228ef1156053997e178da29b4 100644 (file)
@@ -2,7 +2,8 @@
 
 import sys
 
-__all__ = ["warn", "showwarning", "formatwarning", "filterwarnings",
+__all__ = ["warn", "warn_explicit", "showwarning",
+           "formatwarning", "filterwarnings", "simplefilter",
            "resetwarnings", "catch_warnings"]
 
 
index b16dd70feb1474b3a86adf3068392b67e27c196a..4986dc619d5f230275360bcc9ab20d9c97762c5f 100644 (file)
--- 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
index 9c4f5606a3d4626fea66178eabe8b5e6d2979ac1..9396ac906f4db1b44d1fdbe81ece77411822af6a 100644 (file)
--- 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.