Exemplo n.º 1
0
def test_parse_arguments(basic_config):
    """Test the parsing of the commandline arguments"""
    cmdline_parser = CmdlineParser()
    cmdline_parser._parse_arguments(
        "python script.py some pos args --with args --and multiple args "
        "--plus --booleans --equal=value".split(" "))

    assert cmdline_parser.arguments == basic_config
Exemplo n.º 2
0
def test_format(to_format):
    """Test that the format method assigns the correc values"""
    cmdline_parser = CmdlineParser()

    cmdline_parser.parse(to_format.split(' '))

    keys, arguments = cmdline_parser._parse_arguments(to_format.split(' '))

    formatted = cmdline_parser.format(arguments)

    assert formatted == to_format.split(' ')
Exemplo n.º 3
0
def test_parse_fugly_underscores():
    """Test that underscores are kept as such no matter how fugly this is"""
    cmdline_parser = CmdlineParser()
    keys, arguments = cmdline_parser._parse_arguments(
        "pos -my_poor eyes --are_bleeding because --of-these underscores".split(" "))

    assert arguments == OrderedDict((
        ('_pos_0', 'pos'),
        ('my_poor', 'eyes'),
        ('are_bleeding', 'because'),
        ('of-these', 'underscores')))

    assert keys == OrderedDict((
        ('_pos_0', '_pos_0'),
        ('my_poor', '-my_poor'),
        ('are_bleeding', '--are_bleeding'),
        ('of-these', '--of-these')))
Exemplo n.º 4
0
def test_parse_not_enough_dashes():
    """Test that arguments with many chars but one dash are supported even if it is not standard"""
    cmdline_parser = CmdlineParser()
    keys, arguments = cmdline_parser._parse_arguments(
        "pos -not-enough dashes "
        "--enough dashes -o my".split(" "))

    assert arguments == OrderedDict(
        (("_pos_0", "pos"), ("not-enough", "dashes"), ("enough", "dashes"),
         ("o", "my")))

    assert keys == OrderedDict((
        ("_pos_0", "_pos_0"),
        ("not-enough", "-not-enough"),
        ("enough", "--enough"),
        ("o", "-o"),
    ))
Exemplo n.º 5
0
def test_parse_not_enough_dashes():
    """Test that arguments with many chars but one dash are supported even if it is not standard"""
    cmdline_parser = CmdlineParser()
    keys, arguments = cmdline_parser._parse_arguments(
        "pos -not-enough dashes "
        "--enough dashes -o my".split(" "))

    assert arguments == OrderedDict((
        ('_pos_0', 'pos'),
        ('not-enough', 'dashes'),
        ('enough', 'dashes'),
        ('o', 'my')))

    assert keys == OrderedDict((
        ('_pos_0', '_pos_0'),
        ('not-enough', '-not-enough'),
        ('enough', '--enough'),
        ('o', '-o')))
Exemplo n.º 6
0
def test_parse_fugly_underscores():
    """Test that underscores are kept as such no matter how fugly this is"""
    cmdline_parser = CmdlineParser()
    keys, arguments = cmdline_parser._parse_arguments(
        "pos -my_poor eyes --are_bleeding because --of-these underscores".
        split(" "))

    assert arguments == OrderedDict((
        ("_pos_0", "pos"),
        ("my_poor", "eyes"),
        ("are_bleeding", "because"),
        ("of-these", "underscores"),
    ))

    assert keys == OrderedDict((
        ("_pos_0", "_pos_0"),
        ("my_poor", "-my_poor"),
        ("are_bleeding", "--are_bleeding"),
        ("of-these", "--of-these"),
    ))