def test_blocking_acquire(self): lock = TimeoutableLock() self.assert_(lock.acquire()) t = AcquireWithTimeout(lock, None) t.start() lock.release() t.join() self.failIf(lock.acquire(False))
def test_acquire_early(self): lock = TimeoutableLock() self.assert_(lock.acquire()) t = AcquireWithTimeout(lock, 10) before = time.time() t.start() lock.release() t.join() self.assert_(time.time() - before < 1) self.failIf(lock.acquire(False))
def test_basic(self): lock = TimeoutableLock() self.assert_(lock.acquire()) self.failIf(lock.acquire(False)) lock.release() self.assert_(lock.acquire()) lock.release() self.assertRaises(RuntimeError, lock.release)