File: test_run.py

package info (click to toggle)
python-cyclopts 3.12.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,288 kB
  • sloc: python: 11,445; makefile: 24
file content (16 lines) | stat: -rw-r--r-- 374 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from pytest import MonkeyPatch

from cyclopts import App, run


def test_run(monkeypatch: MonkeyPatch):
    def main(input: int) -> int:
        return input * 2

    class TestApp(App):
        def __call__(self, tokens=None, **kwargs):
            return super().__call__("2", **kwargs)

    monkeypatch.setitem(run.__globals__, "App", TestApp)

    assert run(main) == 4