Coverage for tests/test_rich_markup_mode.py: 100%

25 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-03-10 00:15 +0000

1import typer 1abcdefghi

2import typer.completion 1abcdefghi

3from typer.testing import CliRunner 1abcdefghi

4 

5runner = CliRunner() 1abcdefghi

6rounded = ["╭", "─", "┬", "╮", "│", "├", "┼", "┤", "╰", "┴", "╯"] 1abcdefghi

7 

8 

9def test_rich_markup_mode_none(): 1abcdefghi

10 app = typer.Typer(rich_markup_mode=None) 1abcdefghi

11 

12 @app.command() 1abcdefghi

13 def main(arg: str): 1abcdefghi

14 """Main function""" 

15 print(f"Hello {arg}") 1abcdefghi

16 

17 assert app.rich_markup_mode is None 1abcdefghi

18 

19 result = runner.invoke(app, ["World"]) 1abcdefghi

20 assert "Hello World" in result.stdout 1abcdefghi

21 

22 result = runner.invoke(app, ["--help"]) 1abcdefghi

23 assert all(c not in result.stdout for c in rounded) 1abcdefghi

24 

25 

26def test_rich_markup_mode_rich(): 1abcdefghi

27 app = typer.Typer(rich_markup_mode="rich") 1abcdefghi

28 

29 @app.command() 1abcdefghi

30 def main(arg: str): 1abcdefghi

31 """Main function""" 

32 print(f"Hello {arg}") 1abcdefghi

33 

34 assert app.rich_markup_mode == "rich" 1abcdefghi

35 

36 result = runner.invoke(app, ["World"]) 1abcdefghi

37 assert "Hello World" in result.stdout 1abcdefghi

38 

39 result = runner.invoke(app, ["--help"]) 1abcdefghi

40 assert any(c in result.stdout for c in rounded) 1abcdefghi