def test_lock_with_validity(): """ Test a RedLock can be acquired and the lock validity is also retruned. """ ttl = 1000 lock = RedLock("test_simple_lock", [{"host": "localhost"}], ttl=ttl) locked, validity = lock.acquire_with_validity() lock.release() assert locked is True assert 0 < validity < ttl - ttl * CLOCK_DRIFT_FACTOR - 2