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

Method test__run_once

Lib/test/test_asyncio/test_base_events.py:404–420  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

402 test_thread(self.loop, False, create_loop=True)
403
404 def test__run_once(self):
405 h1 = asyncio.TimerHandle(time.monotonic() + 5.0, lambda: True, (),
406 self.loop, None)
407 h2 = asyncio.TimerHandle(time.monotonic() + 10.0, lambda: True, (),
408 self.loop, None)
409
410 h1.cancel()
411
412 self.loop._process_events = mock.Mock()
413 self.loop._scheduled.append(h1)
414 self.loop._scheduled.append(h2)
415 self.loop._run_once()
416
417 t = self.loop._selector.select.call_args[0][0]
418 self.assertTrue(9.5 < t < 10.5, t)
419 self.assertEqual([h2], self.loop._scheduled)
420 self.assertTrue(self.loop._process_events.called)
421
422 def test_set_debug(self):
423 self.loop.set_debug(True)

Callers

nothing calls this directly

Calls 5

cancelMethod · 0.95
assertTrueMethod · 0.80
appendMethod · 0.45
_run_onceMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected