test_selectors: make timeout-related errors report the actual elapsed timeout.

This commit is contained in:
Charles-François Natali 2013-10-25 17:56:00 +02:00
parent 052058fa14
commit c60dd5b0d4
1 changed files with 5 additions and 4 deletions

View File

@ -264,18 +264,19 @@ class BaseSelectorTestCase(unittest.TestCase):
t = time()
self.assertEqual(1, len(s.select(0)))
self.assertEqual(1, len(s.select(-1)))
self.assertTrue(time() - t < 0.5)
self.assertLess(time() - t, 0.5)
s.unregister(wr)
s.register(rd, selectors.EVENT_READ)
t = time()
self.assertFalse(s.select(0))
self.assertFalse(s.select(-1))
self.assertTrue(time() - t < 0.5)
self.assertLess(time() - t, 0.5)
t = time()
t0 = time()
self.assertFalse(s.select(1))
self.assertTrue(0.5 < time() - t < 1.5)
t1 = time()
self.assertTrue(0.5 < t1 - t0 < 1.5, t1 - t0)
@unittest.skipUnless(hasattr(signal, "alarm"),
"signal.alarm() required for this test")