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

Method testAccept

Lib/test/test_socket.py:5496–5516  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

5494 self.cli.connect((HOST, self.port))
5495
5496 def testAccept(self):
5497 # Testing non-blocking accept
5498 self.serv.setblocking(False)
5499
5500 # connect() didn't start: non-blocking accept() fails
5501 start_time = time.monotonic()
5502 with self.assertRaises(BlockingIOError):
5503 conn, addr = self.serv.accept()
5504 dt = time.monotonic() - start_time
5505 self.assertLess(dt, 1.0)
5506
5507 self.event.set()
5508
5509 read, write, err = select.select([self.serv], [], [], support.LONG_TIMEOUT)
5510 if self.serv not in read:
5511 self.fail("Error trying to do accept after select.")
5512
5513 # connect() completed: non-blocking accept() doesn't block
5514 conn, addr = self.serv.accept()
5515 self.addCleanup(conn.close)
5516 self.assertIsNone(conn.gettimeout())
5517
5518 def _testAccept(self):
5519 # don't connect before event is set to check

Callers

nothing calls this directly

Calls 10

addCleanupMethod · 0.80
assertIsNoneMethod · 0.80
setblockingMethod · 0.45
assertRaisesMethod · 0.45
acceptMethod · 0.45
assertLessMethod · 0.45
setMethod · 0.45
selectMethod · 0.45
failMethod · 0.45
gettimeoutMethod · 0.45

Tested by

no test coverage detected