File: test_end2end.py

package info (click to toggle)
python-cyclopts 3.12.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,288 kB
  • sloc: python: 11,445; makefile: 24
file content (34 lines) | stat: -rw-r--r-- 763 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
28
29
30
31
32
33
34
from textwrap import dedent

from cyclopts.config import Toml


def test_config_end2end(app, tmp_path, assert_parse_args):
    config_fn = tmp_path / "config.toml"

    config_fn.write_text(
        dedent(
            """\
            [tool.cyclopts]
            key1 = "foo1"
            key2 = "foo2"

            [tool.cyclopts.function1]
            key3 = "bar1"
            key4 = "bar2"
            """
        )
    )

    app.config = Toml(config_fn, root_keys=["tool", "cyclopts"])

    @app.default
    def default(key1, key2):
        pass

    @app.command
    def function1(key3, key4):
        pass

    assert_parse_args(default, "foo", key1="foo", key2="foo2")
    assert_parse_args(function1, "function1 --key4=fizz", key3="bar1", key4="fizz")