def test_cmd_execution_failed_gives_command_in_exception(mockroot): c = Component() c.prepare(mockroot) with pytest.raises(CmdExecutionError) as e: c.cmd('asdf') assert e.value.cmd == 'asdf' assert e.value.returncode == 127
def test_cmd_should_not_stop_if_process_expects_input(mockroot): c = Component() c.prepare(mockroot) stdout, stderr = c.cmd('cat')
def test_cmd_returns_output_if_ignore_returncode(mockroot): c = Component() c.prepare(mockroot) out, err = c.cmd('echo important output && false', ignore_returncode=True) assert 'important output\n' == out
def test_cmd_raises_if_error(mockroot): c = Component() c.prepare(mockroot) with pytest.raises(CmdExecutionError): c.cmd('non-existing-command')
def test_cmd_returns_output(mockroot): c = Component() c.prepare(mockroot) assert ('1\n', '') == c.cmd('echo 1')
def test_cmd_expands_jinja(mockroot): c = Component() c.foo = 'asdf' c.prepare(mockroot) assert ('asdf\n', '') == c.cmd('echo "{{component.foo}}"')
def test_cmd_returns_output(mockroot): c = Component() c.prepare(mockroot) assert ("1\n", "") == c.cmd("echo 1")
def test_cmd_expands_jinja(mockroot): c = Component() c.foo = "asdf" c.prepare(mockroot) assert ("asdf\n", "") == c.cmd('echo "{{component.foo}}"')