def test_basic_child_process_command(): events = list( filter( lambda x: x, execute_child_process_command( DoubleAStringChildProcessCommand('aa')))) assert events == ['aaaa']
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']
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)
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
def test_long_running_command(): list(execute_child_process_command(LongRunningCommand()))
def test_child_process_crashy_process(): with pytest.raises(ChildProcessCrashException): list(execute_child_process_command(CrashyCommand()))
def test_child_process_uncaught_exception(): with pytest.raises(ChildProcessException) as excinfo: list(execute_child_process_command(ThrowAnErrorCommand())) assert 'AnError' in str(excinfo.value)