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
« 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
5runner = CliRunner() 1abcdefghi
6rounded = ["╭", "─", "┬", "╮", "│", "├", "┼", "┤", "╰", "┴", "╯"] 1abcdefghi
9def test_rich_markup_mode_none(): 1abcdefghi
10 app = typer.Typer(rich_markup_mode=None) 1abcdefghi
12 @app.command() 1abcdefghi
13 def main(arg: str): 1abcdefghi
14 """Main function"""
15 print(f"Hello {arg}") 1abcdefghi
17 assert app.rich_markup_mode is None 1abcdefghi
19 result = runner.invoke(app, ["World"]) 1abcdefghi
20 assert "Hello World" in result.stdout 1abcdefghi
22 result = runner.invoke(app, ["--help"]) 1abcdefghi
23 assert all(c not in result.stdout for c in rounded) 1abcdefghi
26def test_rich_markup_mode_rich(): 1abcdefghi
27 app = typer.Typer(rich_markup_mode="rich") 1abcdefghi
29 @app.command() 1abcdefghi
30 def main(arg: str): 1abcdefghi
31 """Main function"""
32 print(f"Hello {arg}") 1abcdefghi
34 assert app.rich_markup_mode == "rich" 1abcdefghi
36 result = runner.invoke(app, ["World"]) 1abcdefghi
37 assert "Hello World" in result.stdout 1abcdefghi
39 result = runner.invoke(app, ["--help"]) 1abcdefghi
40 assert any(c in result.stdout for c in rounded) 1abcdefghi