Index: Lib/test/test_threadsignals.py =================================================================== --- Lib/test/test_threadsignals.py (révision 88424) +++ Lib/test/test_threadsignals.py (copie de travail) @@ -78,7 +78,14 @@ lock = thread.allocate_lock() lock.acquire() signal.alarm(1) - self.assertRaises(KeyboardInterrupt, lock.acquire) + t1 = time.time() + self.assertRaises(KeyboardInterrupt, lock.acquire, timeout=5) + dt = time.time() - t1 + # Checking that KeyboardInterrupt was raised is not sufficient. + # We want to assert that lock.acquire() was interrupted because + # of the signal, not that the signal handler was called immediately + # after timeout return of lock.acquire() (which can fool assertRaises). + self.assertLess(dt, 3.0) finally: signal.signal(signal.SIGALRM, oldalrm) @@ -98,7 +105,11 @@ rlock.release() time.sleep(0.01) signal.alarm(1) - self.assertRaises(KeyboardInterrupt, rlock.acquire) + t1 = time.time() + self.assertRaises(KeyboardInterrupt, rlock.acquire, timeout=5) + dt = time.time() - t1 + # See rationale above in test_lock_acquire_interruption + self.assertLess(dt, 3.0) finally: signal.signal(signal.SIGALRM, oldalrm)