def test_connection_observer_one_exception():
    ConnectionObserver.get_unraised_exceptions(True)
    time.sleep(0.1)
    from moler.cmd.unix.ls import Ls
    from moler.exceptions import CommandTimeout
    cmd = Ls(None)
    none_exceptions = ConnectionObserver.get_unraised_exceptions(True)
    assert 0 == len(none_exceptions)
    cmd.set_exception(CommandTimeout(cmd, 0.1))
    cmd._is_done = True
    active_exceptions = ConnectionObserver.get_unraised_exceptions(True)
    assert 1 == len(active_exceptions)
    try:
        cmd.result()
    except CommandTimeout:
        pass
    none_exceptions = ConnectionObserver.get_unraised_exceptions(True)
    assert 0 == len(none_exceptions)
    none_exceptions = ConnectionObserver.get_unraised_exceptions(True)
    assert 0 == len(none_exceptions)
示例#2
0
def test_moler_test_not_raise_exception_when_no_steps_end(moler_test):
    ConnectionObserver.get_unraised_exceptions()
    moler_test.test_not_raise_exception_when_no_steps_end()
示例#3
0
def test_moler_test_raise_exception_when_log_error_raise_exception_set(
        moler_test_se):
    ConnectionObserver.get_unraised_exceptions()
    with pytest.raises(MolerStatusException):
        moler_test_se.test_raise_exception_when_log_error_raise_exception_set()
示例#4
0
def test_moler_test_test_raise_exception_when_not_call_steps_end(
        moler_test_se):
    ConnectionObserver.get_unraised_exceptions()
    with pytest.raises(MolerStatusException):
        moler_test_se.test_raise_exception_when_not_call_steps_end()
示例#5
0
def test_moler_test_wrapper():
    ConnectionObserver.get_unraised_exceptions()
    decorated = moler_test_raise_exception_when_no_steps_end_for_global_method
    ret = MolerTest._wrapper(decorated, False)
    assert decorated == ret
示例#6
0
def test_moler_test_raise_exception_when_not_callable_passed():
    ConnectionObserver.get_unraised_exceptions()
    var = "no callable"
    with pytest.raises(MolerStatusException):
        MolerTest._decorate(var)
示例#7
0
def test_moler_test_not_raise_exception_when_no_steps_end_for_global_method_twice(
):
    ConnectionObserver.get_unraised_exceptions()
    moler_test_not_raise_exception_when_no_steps_end_for_global_method_twice()
示例#8
0
def test_moler_test_warn():
    ConnectionObserver.get_unraised_exceptions()
    MolerTest.warning("Warning test")
示例#9
0
def test_moler_test_raise_exception_when_no_steps_end_for_global_method():
    with pytest.raises(ExecutionException):
        moler_test_raise_exception_when_no_steps_end_for_global_method()
    ConnectionObserver.get_unraised_exceptions()
示例#10
0
def test_moler_test_raise_exception_when_log_error(moler_test_se):
    ConnectionObserver.get_unraised_exceptions()
    with pytest.raises(ExecutionException):
        moler_test_se.test_raise_exception_when_log_error()
    ConnectionObserver.get_unraised_exceptions()