test_parser.py
This file
Path
tests/test_parser.py
32 lines · 915 bytes · Python
Last changed by
Not known.
History of this fileTake it
The walk stopped after 200 commits: lines older than c326df9 point at it.
Fix closing of callbacks on CLI exit (#2680)Kevin Deldyckebefore adoptionc326df9
lines 1–32why, one step back1import pytest23import click4from click.parser import _OptionParser5from click.shell_completion 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 == {"-", "--", "+", "!"}