File: test_async.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 (34 lines) | stat: -rw-r--r-- 682 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 cyclopts import App


def test_async_handler():
    app = App()

    @app.command(name="command")
    async def async_handler():
        return "Async handler works"

    assert app("command") == "Async handler works"


def test_async_handler_with_subcommand_works():
    app = App()

    sub_app = App(name="foo")
    app.command(sub_app)

    @sub_app.command(name="bar")
    async def async_handler():
        return "Async handler works"

    assert app("foo bar") == "Async handler works"


def test_handler():
    app = App()

    @app.command(name="command")
    def sync_handler():
        return "Sync handler works"

    assert app("command") == "Sync handler works"