diff options
author | Christian Heimes <christian@cheimes.de> | 2008-02-28 20:02:27 +0000 |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2008-02-28 20:02:27 +0000 |
commit | 70e7ea23f18aacc31f429787645ff8c074c0ad86 (patch) | |
tree | beb83e14c2f9fdd729914234d9979b50a70718c3 /Lib/test/test_socketserver.py | |
parent | 9e7f1d2e965400edcb2c0cb7fee625ef2b595eb5 (diff) | |
download | cpython-git-70e7ea23f18aacc31f429787645ff8c074c0ad86.tar.gz |
Merged revisions 61038,61042-61045,61047,61050,61053,61055-61056,61061-61062,61066,61068,61070,61083,61085,61092-61097,61103-61108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61105 | andrew.kuchling | 2008-02-28 15:03:03 +0100 (Thu, 28 Feb 2008) | 1 line
#2169: make generated HTML more valid
........
r61106 | jeffrey.yasskin | 2008-02-28 19:03:15 +0100 (Thu, 28 Feb 2008) | 4 lines
Prevent SocketServer.ForkingMixIn from waiting on child processes that it
didn't create, in most cases. When there are max_children handlers running, it
will still wait for any child process, not just handler processes.
........
r61107 | raymond.hettinger | 2008-02-28 20:41:24 +0100 (Thu, 28 Feb 2008) | 1 line
Document impending updates to itertools.
........
r61108 | martin.v.loewis | 2008-02-28 20:44:22 +0100 (Thu, 28 Feb 2008) | 1 line
Add 2.6aN uuids.
........
Diffstat (limited to 'Lib/test/test_socketserver.py')
-rw-r--r-- | Lib/test/test_socketserver.py | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py index 25734fdf4a..658056c968 100644 --- a/Lib/test/test_socketserver.py +++ b/Lib/test/test_socketserver.py @@ -2,6 +2,7 @@ Test suite for SocketServer.py. """ +import contextlib import errno import imp import os @@ -109,6 +110,18 @@ class ServerThread(threading.Thread): if verbose: print("thread: done") +@contextlib.contextmanager +def simple_subprocess(testcase): + pid = os.fork() + if pid == 0: + # Don't throw an exception; it would be caught by the test harness. + os._exit(72) + yield None + pid2, status = os.waitpid(pid, 0) + testcase.assertEquals(pid2, pid) + testcase.assertEquals(72 << 8, status) + + class SocketServerTest(unittest.TestCase): """Test all socket servers.""" @@ -211,10 +224,11 @@ class SocketServerTest(unittest.TestCase): self.stream_examine) if HAVE_FORKING: - def test_ThreadingTCPServer(self): - self.run_server(SocketServer.ForkingTCPServer, - SocketServer.StreamRequestHandler, - self.stream_examine) + def test_ForkingTCPServer(self): + with simple_subprocess(self): + self.run_server(SocketServer.ForkingTCPServer, + SocketServer.StreamRequestHandler, + self.stream_examine) if HAVE_UNIX_SOCKETS: def test_UnixStreamServer(self): @@ -229,9 +243,10 @@ class SocketServerTest(unittest.TestCase): if HAVE_FORKING: def test_ForkingUnixStreamServer(self): - self.run_server(ForkingUnixStreamServer, - SocketServer.StreamRequestHandler, - self.stream_examine) + with simple_subprocess(self): + self.run_server(ForkingUnixStreamServer, + SocketServer.StreamRequestHandler, + self.stream_examine) def test_UDPServer(self): self.run_server(SocketServer.UDPServer, @@ -245,9 +260,10 @@ class SocketServerTest(unittest.TestCase): if HAVE_FORKING: def test_ForkingUDPServer(self): - self.run_server(SocketServer.ForkingUDPServer, - SocketServer.DatagramRequestHandler, - self.dgram_examine) + with simple_subprocess(self): + self.run_server(SocketServer.ForkingUDPServer, + SocketServer.DatagramRequestHandler, + self.dgram_examine) # Alas, on Linux (at least) recvfrom() doesn't return a meaningful # client address so this cannot work: |