Coverage for tests / test_tutorial / test_launch / test_tutorial002.py: 100%
16 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-11-09 00:15 +0000
« prev ^ index » next coverage.py v7.13.1, created at 2026-11-09 00:15 +0000
1import subprocess 1abcdefg
2import sys 1abcdefg
3from pathlib import Path 1abcdefg
4from unittest.mock import patch 1abcdefg
6from typer.testing import CliRunner 1abcdefg
8from docs_src.launch import tutorial002_py310 as mod 1abcdefg
10runner = CliRunner() 1abcdefg
13def test_cli(app_dir: Path): 1abcdefg
14 with patch("typer.launch") as launch_mock: 1abcdefg
15 result = runner.invoke(mod.app) 1abcdefg
17 assert result.exit_code == 0 1abcdefg
18 assert "Opening config directory" in result.output 1abcdefg
19 launch_mock.assert_called_with(str(app_dir / "config.json"), locate=True) 1abcdefg
22def test_script(): 1abcdefg
23 result = subprocess.run( 1abcdefg
24 [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"],
25 capture_output=True,
26 encoding="utf-8",
27 )
28 assert "Usage" in result.stdout 1abcdefg