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