File: test_bind_kwargs.py

package info (click to toggle)
python-cyclopts 3.12.0-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,288 kB
  • sloc: python: 11,445; makefile: 24
file content (27 lines) | stat: -rw-r--r-- 718 bytes parent folder | download | duplicates (2)
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
from typing import List


def test_kwargs_list_int(app, assert_parse_args):
    @app.command
    def foo(a: int, **kwargs: List[int]):
        pass

    assert_parse_args(foo, "foo 1 --bar=2 --baz=4 --bar 3", 1, bar=[2, 3], baz=[4])


def test_kwargs_int(app, assert_parse_args):
    @app.command
    def foo(a: int, **kwargs: int):
        pass

    assert_parse_args(foo, "foo 1 --bar=2 --baz 3", 1, bar=2, baz=3)
    assert_parse_args(foo, "foo 1", 1)


def test_args_and_kwargs_int(app, assert_parse_args):
    @app.command
    def foo(a: int, *args: int, **kwargs: int):
        pass

    assert_parse_args(foo, "foo 1 2 3 4 5 --bar=2 --baz 3", 1, 2, 3, 4, 5, bar=2, baz=3)
    assert_parse_args(foo, "foo 1", 1)