Coverage for tests/test_tutorial/test_commands/test_help/test_tutorial006.py: 100%
37 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 os 1abcdefgh
2import subprocess 1abcdefgh
3import sys 1abcdefgh
5from typer.testing import CliRunner 1abcdefgh
7from docs_src.commands.help import tutorial006 as mod 1abcdefgh
9app = mod.app 1abcdefgh
11runner = CliRunner() 1abcdefgh
14def test_main_help(): 1abcdefgh
15 result = runner.invoke(app, ["--help"]) 1abcdefgh
16 assert result.exit_code == 0 1abcdefgh
17 assert "create" in result.output 1abcdefgh
18 assert "Create a new user. ✨" in result.output 1abcdefgh
19 assert "delete" in result.output 1abcdefgh
20 assert "Delete a user. 🔥" in result.output 1abcdefgh
21 assert "Utils and Configs" in result.output 1abcdefgh
22 assert "config" in result.output 1abcdefgh
23 assert "Configure the system. 🔧" in result.output 1abcdefgh
24 assert "Synchronize the system or something fancy like that. ♻" in result.output 1abcdefgh
25 assert "Help and Others" in result.output 1abcdefgh
26 assert "Get help with the system. ❓" in result.output 1abcdefgh
27 assert "Report an issue. 🐛" in result.output 1abcdefgh
30def test_call(): 1abcdefgh
31 # Mainly for coverage
32 result = runner.invoke(app, ["create", "Morty"]) 1abcdefgh
33 assert result.exit_code == 0 1abcdefgh
34 result = runner.invoke(app, ["delete", "Morty"]) 1abcdefgh
35 assert result.exit_code == 0 1abcdefgh
36 result = runner.invoke(app, ["config", "Morty"]) 1abcdefgh
37 assert result.exit_code == 0 1abcdefgh
38 result = runner.invoke(app, ["sync"]) 1abcdefgh
39 assert result.exit_code == 0 1abcdefgh
40 result = runner.invoke(app, ["help"]) 1abcdefgh
41 assert result.exit_code == 0 1abcdefgh
42 result = runner.invoke(app, ["report"]) 1abcdefgh
43 assert result.exit_code == 0 1abcdefgh
46def test_script(): 1abcdefgh
47 result = subprocess.run( 1abcdefgh
48 [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"],
49 capture_output=True,
50 encoding="utf-8",
51 env={**os.environ, "PYTHONIOENCODING": "utf-8"},
52 )
53 assert "Usage" in result.stdout 1abcdefgh