Coverage for tests/test_tutorial/test_using_click/test_tutorial004.py: 100%
22 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 subprocess 1abcdefgh
2import sys 1abcdefgh
4from click.testing import CliRunner 1abcdefgh
6from docs_src.using_click import tutorial004 as mod 1abcdefgh
8runner = CliRunner() 1abcdefgh
11def test_cli(): 1abcdefgh
12 result = runner.invoke(mod.cli, []) 1abcdefgh
13 assert "Usage" in result.stdout 1abcdefgh
14 assert "dropdb" in result.stdout 1abcdefgh
15 assert "sub" in result.stdout 1abcdefgh
18def test_typer(): 1abcdefgh
19 result = runner.invoke(mod.cli, ["sub"]) 1abcdefgh
20 assert "Typer is now below Click, the Click app is the top level" in result.stdout 1abcdefgh
23def test_click_initdb(): 1abcdefgh
24 result = runner.invoke(mod.cli, ["initdb"]) 1abcdefgh
25 assert "Initialized the database" in result.stdout 1abcdefgh
28def test_click_dropdb(): 1abcdefgh
29 result = runner.invoke(mod.cli, ["dropdb"]) 1abcdefgh
30 assert "Dropped the database" in result.stdout 1abcdefgh
33def test_script(): 1abcdefgh
34 result = subprocess.run( 1abcdefgh
35 [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"],
36 capture_output=True,
37 encoding="utf-8",
38 )
39 assert "Usage" in result.stdout 1abcdefgh