Exemple #1
0
def _roundtrip(args):
    if platform.system() != 'Windows':
        return
    joined = windows_join_command_line(args)
    assert isinstance(joined, str)
    split = windows_split_command_line(joined)
    assert isinstance(split, list)
    for s in split:
        assert isinstance(s, str)
    assert split == args
def _append_extra_args_to_command_line(command, extra_args):
    if extra_args is None:
        return command
    else:
        if _is_windows():  # pragma: no cover
            from anaconda_project.internal.windows_cmdline import (windows_split_command_line,
                                                                   windows_join_command_line)
            args = windows_split_command_line(command)
            return windows_join_command_line(args + extra_args)
        else:
            new_command = command
            for arg in extra_args:
                new_command = new_command + " " + quote(arg)
            return new_command
Exemple #3
0
def test_cannot_join_first_arg_with_quote_and_space():
    with pytest.raises(WindowsCommandLineException) as excinfo:
        windows_join_command_line(['foo"bar baz'])
    assert 'Windows does not allow the first arg to have both quotes and spaces' in str(
        excinfo.value)
Exemple #4
0
def test_cannot_join_first_arg_starting_with_quote():
    with pytest.raises(WindowsCommandLineException) as excinfo:
        windows_join_command_line(['"foo'])
    assert 'Windows does not allow the first arg to start with a quote' in str(
        excinfo.value)
Exemple #5
0
def test_empty_args():
    with pytest.raises(WindowsCommandLineException) as excinfo:
        windows_join_command_line([])
    assert "Windows has no way to encode an empty arg list as a command line" in str(
        excinfo.value)