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

Method test_timeout

Lib/test/lock_tests.py:534–563  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

532 self._check_notify(evt)
533
534 def test_timeout(self):
535 evt = self.eventtype()
536 results1 = []
537 results2 = []
538 N = 5
539 def f():
540 results1.append(evt.wait(0.0))
541 t1 = time.monotonic()
542 r = evt.wait(0.5)
543 t2 = time.monotonic()
544 results2.append((r, t2 - t1))
545
546 with Bunch(f, N):
547 pass
548
549 self.assertEqual(results1, [False] * N)
550 for r, dt in results2:
551 self.assertFalse(r)
552 self.assertTimeout(dt, 0.5)
553
554 # The event is set
555 results1 = []
556 results2 = []
557 evt.set()
558 with Bunch(f, N):
559 pass
560
561 self.assertEqual(results1, [True] * N)
562 for r, dt in results2:
563 self.assertTrue(r)
564
565 def test_set_and_clear(self):
566 # gh-57711: check that wait() returns true even when the event is

Callers

nothing calls this directly

Calls 6

assertFalseMethod · 0.80
assertTimeoutMethod · 0.80
assertTrueMethod · 0.80
BunchClass · 0.70
assertEqualMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected