Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(6)

Delta Between Two Patch Sets: Lib/test/test_socketserver.py

Issue 26309: socketserver.BaseServer._handle_request_noblock() don't shutdwon request if verify_request is False
Left Patch Set: Created 4 years ago
Right Patch Set: Created 4 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « Lib/socketserver.py ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 """ 1 """
2 Test suite for socketserver. 2 Test suite for socketserver.
3 """ 3 """
4 4
5 import contextlib 5 import contextlib
6 import os 6 import os
7 import select 7 import select
8 import signal 8 import signal
9 import socket 9 import socket
10 import select 10 import select
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 def test_tcpserver_bind_leak(self): 273 def test_tcpserver_bind_leak(self):
274 # Issue #22435: the server socket wouldn't be closed if bind()/listen() 274 # Issue #22435: the server socket wouldn't be closed if bind()/listen()
275 # failed. 275 # failed.
276 # Create many servers for which bind() will fail, to see if this result 276 # Create many servers for which bind() will fail, to see if this result
277 # in FD exhaustion. 277 # in FD exhaustion.
278 for i in range(1024): 278 for i in range(1024):
279 with self.assertRaises(OverflowError): 279 with self.assertRaises(OverflowError):
280 socketserver.TCPServer((HOST, -1), 280 socketserver.TCPServer((HOST, -1),
281 socketserver.StreamRequestHandler) 281 socketserver.StreamRequestHandler)
282 282
283 def test_shutdown_request_called_if_verify_request_false(self):
284 # Issue #26309: BaseServer should call shutdown_request even if
285 # verify_request is False
286 shutdown_called = False
287
288 class MyServer(socketserver.TCPServer):
289 def verify_request(self, request, client_address):
290 return False
291
292 def shutdown_request(self, request):
293 nonlocal shutdown_called
294 shutdown_called = True
295 super().shutdown_request(request)
296
297 def connect_to_server(proto, addr):
298 s = socket.socket(proto, socket.SOCK_STREAM)
299 s.connect(addr)
300 s.close()
301
302 self.run_server(MyServer,
303 socketserver.StreamRequestHandler,
304 connect_to_server)
305 self.assertEqual(shutdown_called, True)
306
283 307
284 class MiscTestCase(unittest.TestCase): 308 class MiscTestCase(unittest.TestCase):
285 309
286 def test_all(self): 310 def test_all(self):
287 # objects defined in the module should be in __all__ 311 # objects defined in the module should be in __all__
288 expected = [] 312 expected = []
289 for name in dir(socketserver): 313 for name in dir(socketserver):
290 if not name.startswith('_'): 314 if not name.startswith('_'):
291 mod_object = getattr(socketserver, name) 315 mod_object = getattr(socketserver, name)
292 if getattr(mod_object, '__module__', None) == 'socketserver': 316 if getattr(mod_object, '__module__', None) == 'socketserver':
293 expected.append(name) 317 expected.append(name)
294 self.assertCountEqual(socketserver.__all__, expected) 318 self.assertCountEqual(socketserver.__all__, expected)
295 319
296 320
297 if __name__ == "__main__": 321 if __name__ == "__main__":
298 unittest.main() 322 unittest.main()
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+