Coverage for tests/test_callback_warning.py: 100%
26 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-12-19 20:29 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2025-12-19 20:29 +0000
1import pytest 1abcdefghi
2import typer 1abcdefghi
3from typer.testing import CliRunner 1abcdefghi
5runner = CliRunner() 1abcdefghi
8def test_warns_when_callback_is_not_supported(): 1abcdefghi
9 app = typer.Typer() 1abcdefghi
11 sub_app = typer.Typer() 1abcdefghi
13 @sub_app.callback() 1abcdefghi
14 def callback(): 1abcdefghi
15 """This help text is not used."""
17 app.add_typer(sub_app) 1abcdefghi
19 with pytest.warns( 1abcdefghi
20 match="The 'callback' parameter is not supported by Typer when using `add_typer` without a name"
21 ):
22 try: 1abcdefghi
23 app() 1abcdefghi
24 except SystemExit: 1abcdefghi
25 pass 1abcdefghi
28def test_warns_when_callback_is_not_supported_added_after_add_typer(): 1abcdefghi
29 app = typer.Typer() 1abcdefghi
31 sub_app = typer.Typer() 1abcdefghi
32 app.add_typer(sub_app) 1abcdefghi
34 @sub_app.callback() 1abcdefghi
35 def callback(): 1abcdefghi
36 """This help text is not used."""
38 with pytest.warns( 1abcdefghi
39 match="The 'callback' parameter is not supported by Typer when using `add_typer` without a name"
40 ):
41 try: 1abcdefghi
42 app() 1abcdefghi
43 except SystemExit: 1abcdefghi
44 pass 1abcdefghi