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-02-09 12:36 +0000

1from typer.testing import CliRunner 1abcdefgh

2 

3from docs_src.one_file_per_command.app_py39 import main as mod 1abcdefgh

4 

5runner = CliRunner() 1abcdefgh

6 

7 

8def test_help(): 1abcdefgh

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

10 

11 assert result.exit_code == 0 1abcdefgh

12 

13 assert "version" in result.output 1abcdefgh

14 assert "users" in result.output 1abcdefgh

15 

16 

17def test_version(): 1abcdefgh

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

19 

20 assert result.exit_code == 0 1abcdefgh

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

22 

23 

24def test_users_help(): 1abcdefgh

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

26 

27 assert result.exit_code == 0 1abcdefgh

28 

29 assert "add" in result.output 1abcdefgh

30 assert "delete" in result.output 1abcdefgh

31 

32 

33def test_add_user(): 1abcdefgh

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

35 

36 assert result.exit_code == 0 1abcdefgh

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

38 

39 

40def test_delete_user(): 1abcdefgh

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

42 

43 assert result.exit_code == 0 1abcdefgh

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