mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Issue #26404: Add context manager to socketserver, by Aviv Palivoda
This commit is contained in:
parent
7258176c68
commit
0cab9c1eba
11 changed files with 125 additions and 103 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue