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

1from __future__ import annotations 1abcdefgh

2 

3from typing import Annotated 1abcdefgh

4 

5import typer 1abcdefgh

6from typer.testing import CliRunner 1abcdefgh

7 

8runner = CliRunner() 1abcdefgh

9 

10 

11def test_annotated(): 1abcdefgh

12 app = typer.Typer() 1abcdefgh

13 

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

20 

21 result = runner.invoke(app) 1abcdefgh

22 assert result.exit_code == 0, result.output 1abcdefgh

23 assert "Not forcing" in result.output 1abcdefgh

24 

25 result = runner.invoke(app, ["--force"]) 1abcdefgh

26 assert result.exit_code == 0, result.output 1abcdefgh

27 assert "Forcing operation" in result.output 1abcdefgh