def test(): # Create a Lock lock = Lock("test") # Should not be yet held. assert lock.held() == False # Go get it lock.acquire() # Second lock shall throw in debug mode. try: lock.acquire() except AssertionError, e: if str(e) != flock.WriteLock.ERROR_ISLOCKED: raise
def test(): # Create a Lock lock = Lock("test") # Should not be yet held. assert lock.held() == False # Go get it lock.acquire() # Second lock shall throw in debug mode. try: lock.acquire() except AssertionError as e: if str(e) != flock.WriteLock.ERROR_ISLOCKED: raise else: raise AssertionError("Reaquired a locked lock") lock.release() Lock.cleanup()