Commit 1827eff0 authored by Martin Panter's avatar Martin Panter

Issue #5824: Fix DatagramRequestHandler tests by binding the client socket

parent ee3074e1
...@@ -120,11 +120,6 @@ BaseServer: ...@@ -120,11 +120,6 @@ BaseServer:
# Author of the BaseServer patch: Luke Kenneth Casson Leighton # 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" __version__ = "0.4"
...@@ -750,9 +745,6 @@ class StreamRequestHandler(BaseRequestHandler): ...@@ -750,9 +745,6 @@ class StreamRequestHandler(BaseRequestHandler):
class DatagramRequestHandler(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.""" """Define self.rfile and self.wfile for datagram sockets."""
def setup(self): def setup(self):
......
...@@ -160,6 +160,8 @@ class SocketServerTest(unittest.TestCase): ...@@ -160,6 +160,8 @@ class SocketServerTest(unittest.TestCase):
def dgram_examine(self, proto, addr): def dgram_examine(self, proto, addr):
s = socket.socket(proto, socket.SOCK_DGRAM) 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) s.sendto(TEST_STR, addr)
buf = data = receive(s, 100) buf = data = receive(s, 100)
while data and b'\n' not in buf: while data and b'\n' not in buf:
...@@ -222,27 +224,24 @@ class SocketServerTest(unittest.TestCase): ...@@ -222,27 +224,24 @@ class SocketServerTest(unittest.TestCase):
socketserver.DatagramRequestHandler, socketserver.DatagramRequestHandler,
self.dgram_examine) self.dgram_examine)
# Alas, on Linux (at least) recvfrom() doesn't return a meaningful @requires_unix_sockets
# client address so this cannot work: def test_UnixDatagramServer(self):
self.run_server(socketserver.UnixDatagramServer,
# @requires_unix_sockets socketserver.DatagramRequestHandler,
# def test_UnixDatagramServer(self): self.dgram_examine)
# self.run_server(socketserver.UnixDatagramServer,
# socketserver.DatagramRequestHandler, @requires_unix_sockets
# self.dgram_examine) def test_ThreadingUnixDatagramServer(self):
# self.run_server(socketserver.ThreadingUnixDatagramServer,
# @requires_unix_sockets socketserver.DatagramRequestHandler,
# def test_ThreadingUnixDatagramServer(self): self.dgram_examine)
# self.run_server(socketserver.ThreadingUnixDatagramServer,
# socketserver.DatagramRequestHandler, @requires_unix_sockets
# self.dgram_examine) @requires_forking
# def test_ForkingUnixDatagramServer(self):
# @requires_unix_sockets self.run_server(ForkingUnixDatagramServer,
# @requires_forking socketserver.DatagramRequestHandler,
# def test_ForkingUnixDatagramServer(self): self.dgram_examine)
# self.run_server(socketserver.ForkingUnixDatagramServer,
# socketserver.DatagramRequestHandler,
# self.dgram_examine)
@reap_threads @reap_threads
def test_shutdown(self): def test_shutdown(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment