Debian Codegraph @

test/test_autoparse/test_basic_autoparse.py

raw
1 import pytest
2
3
4 def test_basic_positional(check_parse):
5 def func(arg): pass
6
7 check_parse(
8 func,
9 "foo",
10 arg="foo")
11
12
13 @pytest.mark.parametrize('cli_args', [
14 [],
15 ['value'],
16 ['value1', 'value2']
17 ])
18 def test_variadic_positional(check_parse, cli_args):
19 check_parse(
20 lambda arg1, *args: None,
21 'arg1_value', *cli_args,
22 arg1='arg1_value', args=cli_args)
23
24
25 def test_optional_default(check_parse):
26 check_parse(
27 lambda arg="default_value": None,
28 arg="default_value")
29
30
31 @pytest.mark.parametrize('flags, result', [
32 ([], False),
33 (['-f'], True),
34 (['--no-flag'], False),
35 (['--no-flag', '-f'], True),
36 (['--flag', '--no-flag'], False)
37 ])
38 def test_add_nos(check_parse, flags, result):
39 def func(flag: bool): pass
40
41 check_parse(
42 func,
43 *flags,
44 add_nos=True,
45 flag=result)