Skip to content
Myr

test_parser.py

This file

Path

tests/test_parser.py

32 lines · 902 bytes · Python

Last changed by

Merge pull request #2041 from spanglerco/shell-completion-option-valuesDavid Lordbefore adoptionef11be6

History of this file

Take it

1import pytest23import click4from click.parser import OptionParser5from click.parser import split_arg_string678@pytest.mark.parametrize(9    ("value", "expect"),10    [11        ("cli a b c", ["cli", "a", "b", "c"]),12        ("cli 'my file", ["cli", "my file"]),13        ("cli 'my file'", ["cli", "my file"]),14        ("cli my\\", ["cli", "my"]),15        ("cli my\\ file", ["cli", "my file"]),16    ],17)18def test_split_arg_string(value, expect):19    assert split_arg_string(value) == expect202122def test_parser_default_prefixes():23    parser = OptionParser()24    assert parser._opt_prefixes == {"-", "--"}252627def test_parser_collects_prefixes():28    ctx = click.Context(click.Command("test"))29    parser = OptionParser(ctx)30    click.Option("+p", is_flag=True).add_to_parser(parser, ctx)31    click.Option("!e", is_flag=True).add_to_parser(parser, ctx)32    assert parser._opt_prefixes == {"-", "--", "+", "!"}