1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
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 == {"-", "--", "+", "!"}
|