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