summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2016-02-24 06:14:15 (GMT)
committerMartin Panter <vadmium+py@gmail.com>2016-02-24 06:14:15 (GMT)
commit510addf63f484da826ad1886c4ed14f6395e4018 (patch)
tree0635c541d2a486e3db6143f9407bebc0c6611e0b
parent150ea1a1dffd624b4cd6c2608ece249d12588907 (diff)
parent1827eff03087d0e7975806967a68a349e10e5188 (diff)
downloadcpython-510addf63f484da826ad1886c4ed14f6395e4018.zip
cpython-510addf63f484da826ad1886c4ed14f6395e4018.tar.gz
cpython-510addf63f484da826ad1886c4ed14f6395e4018.tar.bz2
Issue #5824: Merge socketserver tests from 3.5
-rw-r--r--Lib/socketserver.py8
-rw-r--r--Lib/test/test_socketserver.py41
2 files changed, 20 insertions, 29 deletions
diff --git a/Lib/socketserver.py b/Lib/socketserver.py
index 64689991..2f39514 100644
--- a/Lib/socketserver.py
+++ b/Lib/socketserver.py
@@ -120,11 +120,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"
@@ -755,9 +750,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 bff0ff4..27fe01c 100644
--- a/Lib/test/test_socketserver.py
+++ b/Lib/test/test_socketserver.py
@@ -161,6 +161,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 b'\n' not in buf:
@@ -223,27 +225,24 @@ class SocketServerTest(unittest.TestCase):
socketserver.DatagramRequestHandler,
self.dgram_examine)
- # 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):