[Python-checkins] cpython (3.4): Issue #23358: Add missing BaseServer entry to socketserver.__all__.

berker.peksag python-checkins at python.org
Tue Feb 3 10:55:27 CET 2015


https://hg.python.org/cpython/rev/e614ff664877
changeset:   94484:e614ff664877
branch:      3.4
parent:      94480:e62d54128bd3
user:        Berker Peksag <berker.peksag at gmail.com>
date:        Tue Feb 03 11:55:09 2015 +0200
summary:
  Issue #23358: Add missing BaseServer entry to socketserver.__all__.

Patch by Martin Panter.

files:
  Lib/socketserver.py           |   8 ++++----
  Lib/test/test_socketserver.py |  19 ++++++++++++-------
  2 files changed, 16 insertions(+), 11 deletions(-)


diff --git a/Lib/socketserver.py b/Lib/socketserver.py
--- a/Lib/socketserver.py
+++ b/Lib/socketserver.py
@@ -138,10 +138,10 @@
 except ImportError:
     import dummy_threading as threading
 
-__all__ = ["TCPServer","UDPServer","ForkingUDPServer","ForkingTCPServer",
-           "ThreadingUDPServer","ThreadingTCPServer","BaseRequestHandler",
-           "StreamRequestHandler","DatagramRequestHandler",
-           "ThreadingMixIn", "ForkingMixIn"]
+__all__ = ["BaseServer", "TCPServer", "UDPServer", "ForkingUDPServer",
+           "ForkingTCPServer", "ThreadingUDPServer", "ThreadingTCPServer",
+           "BaseRequestHandler", "StreamRequestHandler",
+           "DatagramRequestHandler", "ThreadingMixIn", "ForkingMixIn"]
 if hasattr(socket, "AF_UNIX"):
     __all__.extend(["UnixStreamServer","UnixDatagramServer",
                     "ThreadingUnixStreamServer",
diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py
--- a/Lib/test/test_socketserver.py
+++ b/Lib/test/test_socketserver.py
@@ -2,7 +2,6 @@
 Test suite for socketserver.
 """
 
-import _imp as imp
 import contextlib
 import os
 import select
@@ -313,12 +312,18 @@
                                        socketserver.StreamRequestHandler)
 
 
-def test_main():
-    if imp.lock_held():
-        # If the import lock is held, the threads will hang
-        raise unittest.SkipTest("can't run when import lock is held")
+class MiscTestCase(unittest.TestCase):
 
-    test.support.run_unittest(SocketServerTest)
+    def test_all(self):
+        # objects defined in the module should be in __all__
+        expected = []
+        for name in dir(socketserver):
+            if not name.startswith('_'):
+                mod_object = getattr(socketserver, name)
+                if getattr(mod_object, '__module__', None) == 'socketserver':
+                    expected.append(name)
+        self.assertCountEqual(socketserver.__all__, expected)
+
 
 if __name__ == "__main__":
-    test_main()
+    unittest.main()

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list