コード例 #1
0
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
コード例 #2
0
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
コード例 #3
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
コード例 #4
0
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)
コード例 #5
0
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)
コード例 #6
0
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()