def test_failure(self): lock_stub = pretend.stub(acquire=pretend.call_recorder(lambda: False)) r = pretend.stub(lock=lambda *a, **kw: lock_stub) test_lock = SearchLock(r) with pytest.raises(redis.exceptions.LockError): test_lock.__enter__() assert lock_stub.acquire.calls == [pretend.call()]
def test_success(self): lock_stub = pretend.stub(acquire=pretend.call_recorder(lambda: True)) r = pretend.stub(lock=lambda *a, **kw: lock_stub) test_lock = SearchLock(r) test_lock.__enter__() assert lock_stub.acquire.calls == [pretend.call()]