1234567891011121314151617181920212223242526272829303132 |
- import pytest
- import click
- from click.parser import OptionParser
- from click.parser import split_arg_string
- @pytest.mark.parametrize(
- ("value", "expect"),
- [
- ("cli a b c", ["cli", "a", "b", "c"]),
- ("cli 'my file", ["cli", "my file"]),
- ("cli 'my file'", ["cli", "my file"]),
- ("cli my\\", ["cli", "my"]),
- ("cli my\\ file", ["cli", "my file"]),
- ],
- )
- def test_split_arg_string(value, expect):
- assert split_arg_string(value) == expect
- def test_parser_default_prefixes():
- parser = OptionParser()
- assert parser._opt_prefixes == {"-", "--"}
- def test_parser_collects_prefixes():
- ctx = click.Context(click.Command("test"))
- parser = OptionParser(ctx)
- click.Option("+p", is_flag=True).add_to_parser(parser, ctx)
- click.Option("!e", is_flag=True).add_to_parser(parser, ctx)
- assert parser._opt_prefixes == {"-", "--", "+", "!"}
|