コード例 #1
0
def test_passes_the_script_return_code_to_the_caller(p_Popen, app_conf):
    p_proc = Mock()
    p_Popen.return_value = p_proc
    p_proc.returncode = -99

    result = exec_script_command('fake-cmd', False)

    assert result == -99
コード例 #2
0
def test_prints_return_code_to_stdout(p_Popen, app_conf):
    p_proc = Mock()
    p_Popen.return_value = p_proc
    p_proc.returncode = -99

    result = exec_script_command('fake-cmd', False)

    assert result == -99
コード例 #3
0
def test_will_kill_subprocess_if_KeyboardInterrupt_is_raised(
        p_Popen, app_conf):
    p_proc = Mock()
    p_Popen.return_value = p_proc
    p_proc.communicate.side_effect = KeyboardInterrupt()

    result = exec_script_command('fake-cmd', False)

    assert result == -1
    p_proc.kill.assert_called_once()
コード例 #4
0
def test_executes_the_command_if_pretend_is_False(p_Popen, app_conf):
    exec_script_command('fake-cmd', False)

    p_Popen.assert_called_once_with('fake-cmd', shell=True)
コード例 #5
0
def test_does_not_execute_the_command_if_pretend_is_True(p_Popen):
    exec_script_command('fake-cmd', True)

    p_Popen.assert_not_called()