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

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

index 2c5dbefb3a037df4b7b837207150c5aefab00c07..789f9fbf24fc5e204a4212e3a7b8ddcf57b37178 100644 (file)
@@ -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
index a770ba20f5abfbd121e13d72a21a15583206ae40..fb2046e99c44f9de0d140ad562f01d7d7ced316e 100644 (file)
@@ -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):
 
index 08b70afbad7edadb972b884423a6530907135f30..bf9a5d86e14b4038795ab33d6ec6349078f4a22e 100644 (file)
@@ -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"]
 
 
index 4ebe074824b4f1e6263dd0a816dcdec580528a8a..f9a4426b9999571ea4a8398a93b1379d425b734c 100644 (file)
--- 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
index 47ea77651617959b7d3056ee02696494dc395460..cbe93b11e345d48e3961c23fda9735724b094c85 100644 (file)
--- 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.