MCPcopy Index your code
hub / github.com/python/cpython / test_accept

Method test_accept

Lib/test/_test_eintr.py:308–330  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

306 self._test_send(lambda sock, data: sock.sendmsg([data]))
307
308 def test_accept(self):
309 sock = socket.create_server((socket_helper.HOST, 0))
310 self.addCleanup(sock.close)
311 port = sock.getsockname()[1]
312
313 code = '\n'.join((
314 'import socket, time',
315 '',
316 f'host = {socket_helper.HOST!r}',
317 f'port = {port}',
318 f'sleep_time = {self.sleep_time!r}',
319 '',
320 '# let parent block on accept()',
321 'time.sleep(sleep_time)',
322 'with socket.create_connection((host, port)):',
323 ' time.sleep(sleep_time)',
324 ))
325
326 proc = self.subprocess(code)
327 with kill_on_error(proc):
328 client_sock, _ = sock.accept()
329 client_sock.close()
330 self.assertEqual(proc.wait(), 0)
331
332 # Issue #25122: There is a race condition in the FreeBSD kernel on
333 # handling signals in the FIFO device. Skip the test until the bug is

Callers

nothing calls this directly

Calls 10

addCleanupMethod · 0.80
subprocessMethod · 0.80
kill_on_errorFunction · 0.70
create_serverMethod · 0.45
getsocknameMethod · 0.45
joinMethod · 0.45
acceptMethod · 0.45
closeMethod · 0.45
assertEqualMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected