Exemplo n.º 1
0
def test_failer_immediate():
    failer = testutil.Failer(fail=lambda e: True,
                             message="Expected failure.",
                             engine=None)

    with raises(AssertionError):
        failer.on_idle(Idle(0.0), lambda x: None)
Exemplo n.º 2
0
def test_quitter(loop_count):
    quitter = testutil.Quitter(loop_count=loop_count)
    signal_mock = Mock()
    for i in range(loop_count):
        quitter.__event__(Idle(.01), signal_mock)
    signal_mock.assert_called_once()
    assert len(signal_mock.call_args[0]) == 1
    assert len(signal_mock.call_args[1]) == 0
    assert isinstance(signal_mock.call_args[0][0], Quit)
Exemplo n.º 3
0
def test_failer_timed():
    failer = testutil.Failer(fail=lambda e: False, message="Should time out", run_time=0.1, engine=None)

    start_time = monotonic()

    while True:
        try:
            failer.__event__(Idle(0.0), lambda x: None)
        except AssertionError as e:
            if e.args[0] == "Test ran too long.":
                end_time = monotonic()
                break
            else:
                raise

    run_time = end_time - start_time

    assert abs(run_time - 0.1) <= 0.011