Issue #26404: Add context manager to socketserver, by Aviv Palivoda

This commit is contained in:
Martin Panter 2016-04-13 00:36:52 +00:00
parent 7258176c68
commit 0cab9c1eba
11 changed files with 125 additions and 103 deletions

View file

@ -104,7 +104,6 @@ class SocketServerTest(unittest.TestCase):
class MyServer(svrcls):
def handle_error(self, request, client_address):
self.close_request(request)
self.server_close()
raise
class MyHandler(hdlrbase):
@ -280,6 +279,12 @@ class SocketServerTest(unittest.TestCase):
socketserver.TCPServer((HOST, -1),
socketserver.StreamRequestHandler)
def test_context_manager(self):
with socketserver.TCPServer((HOST, 0),
socketserver.StreamRequestHandler) as server:
pass
self.assertEqual(-1, server.socket.fileno())
class ErrorHandlerTest(unittest.TestCase):
"""Test that the servers pass normal exceptions from the handler to