diff options
author | Martin Panter <vadmium+py@gmail.com> | 2016-02-24 04:45:33 (GMT) |
---|---|---|
committer | Martin Panter <vadmium+py@gmail.com> | 2016-02-24 04:45:33 (GMT) |
commit | 098f6d0caa811ffcdd700ddde7d2558bb823390f (patch) | |
tree | f5c0c44c1f63b308c875a090b3a8224f51f70117 /Lib | |
parent | 39267c21cc8e5e7bc8facd1260eac212b9ebeefd (diff) | |
download | cpython-098f6d0caa811ffcdd700ddde7d2558bb823390f.zip cpython-098f6d0caa811ffcdd700ddde7d2558bb823390f.tar.gz cpython-098f6d0caa811ffcdd700ddde7d2558bb823390f.tar.bz2 |
Issue #5824: Fix DatagramRequestHandler tests by binding the client socket
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/SocketServer.py | 8 | ||||
-rw-r--r-- | Lib/test/test_socketserver.py | 41 |
2 files changed, 20 insertions, 29 deletions
diff --git a/Lib/SocketServer.py b/Lib/SocketServer.py index 80130b7..d324a21 100644 --- a/Lib/SocketServer.py +++ b/Lib/SocketServer.py @@ -121,11 +121,6 @@ BaseServer: # Author of the BaseServer patch: Luke Kenneth Casson Leighton -# XXX Warning! -# There is a test suite for this module, but it cannot be run by the -# standard regression test. -# To run it manually, run Lib/test/test_socketserver.py. - __version__ = "0.4" @@ -721,9 +716,6 @@ class StreamRequestHandler(BaseRequestHandler): class DatagramRequestHandler(BaseRequestHandler): - # XXX Regrettably, I cannot get this working on Linux; - # s.recvfrom() doesn't return a meaningful client address. - """Define self.rfile and self.wfile for datagram sockets.""" def setup(self): diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py index 2550290..d645d20 100644 --- a/Lib/test/test_socketserver.py +++ b/Lib/test/test_socketserver.py @@ -175,6 +175,8 @@ class SocketServerTest(unittest.TestCase): def dgram_examine(self, proto, addr): s = socket.socket(proto, socket.SOCK_DGRAM) + if HAVE_UNIX_SOCKETS and proto == socket.AF_UNIX: + s.bind(self.pickaddr(proto)) s.sendto(TEST_STR, addr) buf = data = receive(s, 100) while data and '\n' not in buf: @@ -269,27 +271,24 @@ class SocketServerTest(unittest.TestCase): # Make sure select was called again: self.assertGreater(mock_select.called, 1) - # Alas, on Linux (at least) recvfrom() doesn't return a meaningful - # client address so this cannot work: - - # @requires_unix_sockets - # def test_UnixDatagramServer(self): - # self.run_server(SocketServer.UnixDatagramServer, - # SocketServer.DatagramRequestHandler, - # self.dgram_examine) - # - # @requires_unix_sockets - # def test_ThreadingUnixDatagramServer(self): - # self.run_server(SocketServer.ThreadingUnixDatagramServer, - # SocketServer.DatagramRequestHandler, - # self.dgram_examine) - # - # @requires_unix_sockets - # @requires_forking - # def test_ForkingUnixDatagramServer(self): - # self.run_server(SocketServer.ForkingUnixDatagramServer, - # SocketServer.DatagramRequestHandler, - # self.dgram_examine) + @requires_unix_sockets + def test_UnixDatagramServer(self): + self.run_server(SocketServer.UnixDatagramServer, + SocketServer.DatagramRequestHandler, + self.dgram_examine) + + @requires_unix_sockets + def test_ThreadingUnixDatagramServer(self): + self.run_server(SocketServer.ThreadingUnixDatagramServer, + SocketServer.DatagramRequestHandler, + self.dgram_examine) + + @requires_unix_sockets + @requires_forking + def test_ForkingUnixDatagramServer(self): + self.run_server(ForkingUnixDatagramServer, + SocketServer.DatagramRequestHandler, + self.dgram_examine) @reap_threads def test_shutdown(self): |