[Python-checkins] cpython (2.7): Issue #5824: Fix DatagramRequestHandler tests by binding the client socket
martin.panter
python-checkins at python.org
Wed Feb 24 01:30:16 EST 2016
https://hg.python.org/cpython/rev/92ae4a305858
changeset: 100309:92ae4a305858
branch: 2.7
parent: 100306:c62526580ff0
user: Martin Panter <vadmium+py at gmail.com>
date: Wed Feb 24 04:45:33 2016 +0000
summary:
Issue #5824: Fix DatagramRequestHandler tests by binding the client socket
files:
Lib/SocketServer.py | 8 ----
Lib/test/test_socketserver.py | 39 +++++++++++-----------
2 files changed, 19 insertions(+), 28 deletions(-)
diff --git a/Lib/SocketServer.py b/Lib/SocketServer.py
--- a/Lib/SocketServer.py
+++ b/Lib/SocketServer.py
@@ -121,11 +121,6 @@
# 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 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
--- a/Lib/test/test_socketserver.py
+++ b/Lib/test/test_socketserver.py
@@ -175,6 +175,8 @@
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 @@
# 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_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_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):
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list