Coverage for tests / test_tutorial / test_one_file_per_command / test_tutorial.py: 100%

25 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-11-18 11:12 +0000

1from typer.testing import CliRunner 1abcdefghij

2 

3from docs_src.one_file_per_command.app import main as mod 1abcdefghij

4 

5runner = CliRunner() 1abcdefghij

6 

7 

8def test_help(): 1abcdefghij

9 result = runner.invoke(mod.app, ["--help"]) 1abcdefghij

10 

11 assert result.exit_code == 0 1abcdefghij

12 

13 assert "version" in result.output 1abcdefghij

14 assert "users" in result.output 1abcdefghij

15 

16 

17def test_version(): 1abcdefghij

18 result = runner.invoke(mod.app, ["version"]) 1abcdefghij

19 

20 assert result.exit_code == 0 1abcdefghij

21 assert "My CLI Version 1.0" in result.output 1abcdefghij

22 

23 

24def test_users_help(): 1abcdefghij

25 result = runner.invoke(mod.app, ["users", "--help"]) 1abcdefghij

26 

27 assert result.exit_code == 0 1abcdefghij

28 

29 assert "add" in result.output 1abcdefghij

30 assert "delete" in result.output 1abcdefghij

31 

32 

33def test_add_user(): 1abcdefghij

34 result = runner.invoke(mod.app, ["users", "add", "Camila"]) 1abcdefghij

35 

36 assert result.exit_code == 0 1abcdefghij

37 assert "Adding user: Camila" in result.output 1abcdefghij

38 

39 

40def test_delete_user(): 1abcdefghij

41 result = runner.invoke(mod.app, ["users", "delete", "Camila"]) 1abcdefghij

42 

43 assert result.exit_code == 0 1abcdefghij

44 assert "Deleting user: Camila" in result.output 1abcdefghij