Example #1
0
def test_parse_multiple_args_without_equal():
    """
    Parsing multiple -e options to "run".
    :return:
    """
    text = 'run --name boo -e FOO 1 -e BOO 2 ubuntu'
    tokens = shlex_split(text) if text else ['']
    cmd = tokens[0]
    params = tokens[1:]

    with pytest.raises(OptionError) as ex:
        parse_command_options(cmd, params)
        assert 'KEY=VALUE' in ex.message
Example #2
0
def test_parse_multiple_args_without_equal():
    """
    Parsing multiple -e options to "run".
    :return:
    """
    text = 'run --name boo -e FOO 1 -e BOO 2 ubuntu'
    tokens = shlex_split(text) if text else ['']
    cmd = tokens[0]
    params = tokens[1:]

    with pytest.raises(OptionError) as ex:
        parse_command_options(cmd, params)
        assert 'KEY=VALUE' in ex.message
Example #3
0
def test_external_command_line(text, is_long, expected):
    """
    Parse and reconstruct the command line.
    """
    cmd, params = text.split(' ', 1)
    params = shlex_split(params)

    parser, popts, pargs = parse_command_options(cmd, params)

    result = format_command_line(cmd, is_long, pargs, popts)

    result_words = set(result.split(' ')[1:])
    expected_words = set(expected.split(' '))

    assert result_words == expected_words
Example #4
0
def test_external_command_line(text, is_long, expected):
    """
    Parse and reconstruct the command line.
    """
    cmd, params = text.split(' ', 1)
    params = shlex_split(params)

    parser, popts, pargs = parse_command_options(cmd, params)

    result = format_command_line(cmd, is_long, pargs, popts)

    result_words = set(result.split(' ')[1:])
    expected_words = set(expected.split(' '))

    assert result_words == expected_words