コード例 #1
0
def test_basic_child_process_command():
    events = list(
        filter(
            lambda x: x and not isinstance(x, ChildProcessEvent),
            execute_child_process_command(DoubleAStringChildProcessCommand('aa')),
        )
    )
    assert events == ['aaaa']
コード例 #2
0
def test_child_process_uncaught_exception():
    results = list(
        filter(
            lambda x: x and isinstance(x, ChildProcessSystemErrorEvent),
            execute_child_process_command(ThrowAnErrorCommand()),
        ))
    assert len(results) == 1

    assert 'AnError' in str(results[0].error_info.message)
コード例 #3
0
def test_basic_child_process_command_with_process_events():
    events = list(
        filter(lambda x: x, execute_child_process_command(DoubleAStringChildProcessCommand('aa')))
    )
    assert len(events) == 3

    assert isinstance(events[0], ChildProcessStartEvent)
    child_pid = events[0].pid
    assert child_pid != os.getpid()
    assert events[1] == 'aaaa'
    assert isinstance(events[2], ChildProcessDoneEvent)
    assert events[2].pid == child_pid
コード例 #4
0
def test_long_running_command():
    list(execute_child_process_command(LongRunningCommand()))
コード例 #5
0
def test_child_process_crashy_process():
    with pytest.raises(ChildProcessCrashException):
        list(execute_child_process_command(CrashyCommand()))
コード例 #6
0
def test_child_process_segfault():
    with pytest.raises(ChildProcessCrashException) as exc:
        list(execute_child_process_command(multiprocessing, SegfaultCommand()))
    assert exc.value.exit_code == -11
コード例 #7
0
def test_child_process_crashy_process():
    with pytest.raises(ChildProcessCrashException) as exc:
        list(execute_child_process_command(CrashyCommand()))
    assert exc.value.exit_code == 1