Coverage for tests/test_rich_markup_mode.py: 100%
25 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-09 18:26 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-09 18:26 +0000
1import typer 1abcdefgh
2import typer.completion 1abcdefgh
3from typer.testing import CliRunner 1abcdefgh
5runner = CliRunner() 1abcdefgh
6rounded = ["╭", "─", "┬", "╮", "│", "├", "┼", "┤", "╰", "┴", "╯"] 1abcdefgh
9def test_rich_markup_mode_none(): 1abcdefgh
10 app = typer.Typer(rich_markup_mode=None) 1abcdefgh
12 @app.command() 1abcdefgh
13 def main(arg: str): 1abcdefgh
14 """Main function"""
15 print(f"Hello {arg}") 1abcdefgh
17 assert app.rich_markup_mode is None 1abcdefgh
19 result = runner.invoke(app, ["World"]) 1abcdefgh
20 assert "Hello World" in result.stdout 1abcdefgh
22 result = runner.invoke(app, ["--help"]) 1abcdefgh
23 assert all(c not in result.stdout for c in rounded) 1abcdefgh
26def test_rich_markup_mode_rich(): 1abcdefgh
27 app = typer.Typer(rich_markup_mode="rich") 1abcdefgh
29 @app.command() 1abcdefgh
30 def main(arg: str): 1abcdefgh
31 """Main function"""
32 print(f"Hello {arg}") 1abcdefgh
34 assert app.rich_markup_mode == "rich" 1abcdefgh
36 result = runner.invoke(app, ["World"]) 1abcdefgh
37 assert "Hello World" in result.stdout 1abcdefgh
39 result = runner.invoke(app, ["--help"]) 1abcdefgh
40 assert any(c in result.stdout for c in rounded) 1abcdefgh