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

Method test_timer_comparison

Lib/test/test_asyncio/test_events.py:2647–2726  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2645
2646
2647 def test_timer_comparison(self):
2648 def callback(*args):
2649 return args
2650
2651 when = time.monotonic()
2652
2653 h1 = asyncio.TimerHandle(when, callback, (), self.loop)
2654 h2 = asyncio.TimerHandle(when, callback, (), self.loop)
2655 with self.assertRaises(AssertionError):
2656 self.assertLess(h1, h2)
2657 with self.assertRaises(AssertionError):
2658 self.assertLess(h2, h1)
2659 with self.assertRaises(AssertionError):
2660 self.assertGreater(h1, h2)
2661 with self.assertRaises(AssertionError):
2662 self.assertGreater(h2, h1)
2663 with self.assertRaises(AssertionError):
2664 self.assertNotEqual(h1, h2)
2665
2666 self.assertLessEqual(h1, h2)
2667 self.assertLessEqual(h2, h1)
2668 self.assertGreaterEqual(h1, h2)
2669 self.assertGreaterEqual(h2, h1)
2670 self.assertEqual(h1, h2)
2671
2672 h2.cancel()
2673 with self.assertRaises(AssertionError):
2674 self.assertEqual(h1, h2)
2675 self.assertNotEqual(h1, h2)
2676
2677 h1 = asyncio.TimerHandle(when, callback, (), self.loop)
2678 h2 = asyncio.TimerHandle(when + 10.0, callback, (), self.loop)
2679 with self.assertRaises(AssertionError):
2680 self.assertLess(h2, h1)
2681 with self.assertRaises(AssertionError):
2682 self.assertLessEqual(h2, h1)
2683 with self.assertRaises(AssertionError):
2684 self.assertGreater(h1, h2)
2685 with self.assertRaises(AssertionError):
2686 self.assertGreaterEqual(h1, h2)
2687 with self.assertRaises(AssertionError):
2688 self.assertEqual(h1, h2)
2689
2690 self.assertLess(h1, h2)
2691 self.assertGreater(h2, h1)
2692 self.assertLessEqual(h1, h2)
2693 self.assertGreaterEqual(h2, h1)
2694 self.assertNotEqual(h1, h2)
2695
2696 h3 = asyncio.Handle(callback, (), self.loop)
2697 self.assertIs(NotImplemented, h1.__eq__(h3))
2698 self.assertIs(NotImplemented, h1.__ne__(h3))
2699
2700 with self.assertRaises(TypeError):
2701 h1 < ()
2702 with self.assertRaises(TypeError):
2703 h1 > ()
2704 with self.assertRaises(TypeError):

Callers

nothing calls this directly

Calls 11

cancelMethod · 0.95
__eq__Method · 0.95
assertGreaterMethod · 0.80
assertNotEqualMethod · 0.80
assertLessEqualMethod · 0.80
assertGreaterEqualMethod · 0.80
assertRaisesMethod · 0.45
assertLessMethod · 0.45
assertEqualMethod · 0.45
assertIsMethod · 0.45
__ne__Method · 0.45

Tested by

no test coverage detected