Coverage for tests / test_future_annotations.py: 100%
18 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-03-26 21:46 +0000
« prev ^ index » next coverage.py v7.13.1, created at 2026-03-26 21:46 +0000
1from __future__ import annotations 1abcdefg
3from typing import Annotated 1abcdefg
5import typer 1abcdefg
6from typer.testing import CliRunner 1abcdefg
8runner = CliRunner() 1abcdefg
11def test_annotated(): 1abcdefg
12 app = typer.Typer() 1abcdefg
14 @app.command() 1abcdefg
15 def cmd(force: Annotated[bool, typer.Option("--force")] = False): 1abcdefg
16 if force: 1abcdefg
17 print("Forcing operation") 1abcdefg
18 else:
19 print("Not forcing") 1abcdefg
21 result = runner.invoke(app) 1abcdefg
22 assert result.exit_code == 0, result.output 1abcdefg
23 assert "Not forcing" in result.output 1abcdefg
25 result = runner.invoke(app, ["--force"]) 1abcdefg
26 assert result.exit_code == 0, result.output 1abcdefg
27 assert "Forcing operation" in result.output 1abcdefg