def test_to_function_with_success_after_waiting(actor, mocker): mocker.patch('time.sleep') wait_actor = wait(actor, timeout=1, interval=0) on_actor = on(wait_actor, counter) to(on_actor, be, value=10) time.sleep.assert_called_with(0) global COUNTER assert COUNTER == 10
def test_wait_function_with_explicit_args(actor): wait_actor = wait(actor, timeout=15, interval=0) assert wait_actor.traits['timeout'] == 15 assert wait_actor.traits['interval'] == 0
def test_wait_function_with_default_args(actor): wait_actor = wait(actor) assert wait_actor.traits['timeout'] == 30 assert wait_actor.traits['interval'] == 1
def test_to_function_with_non_condition(actor): wait_actor = wait(actor, timeout=0.01, interval=0) on_actor = on(wait_actor, always_one) with pytest.raises(NotConditionError): to(on_actor, always_one)
def test_to_function_with_failure_after_waiting(actor): wait_actor = wait(actor, timeout=0.01, interval=0) on_actor = on(wait_actor, always_one) with pytest.raises(WaitTimeoutError): to(on_actor, be, value=2)
def test_to_function_with_success_after_no_need_to_wait(actor, mocker): mocker.patch('time.sleep') wait_actor = wait(actor, timeout=1, interval=0.01) on_actor = on(wait_actor, always_one) to(on_actor, be, value=1) time.sleep.assert_not_called()