def test_basic_locking(fake_redis): """Check if single process locking works""" root_prox = Proxy(path=('QualityControl', )) root_prox.clear() root_prox.acquire() assert root_prox.is_locked() root_prox.set('child', {}) root_prox.release()
def test_locking_edge_cases(fake_redis): """See if locking edge cases like recursive locks work""" root_prox = Proxy(path=('QualityControl', )) root_prox.clear() assert not root_prox.is_locked() # This should work for the same thread: with root_prox: assert root_prox.is_locked() with root_prox: assert root_prox.is_locked() assert not root_prox.is_locked() # See if the lock is released when an exception happens # inside the with block. with pytest.raises(KeyError): with root_prox: raise KeyError("Inside job") assert not root_prox.is_locked()