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-18 11:12 +0000

1import subprocess 1abcdefghij

2import sys 1abcdefghij

3from pathlib import Path 1abcdefghij

4from unittest.mock import patch 1abcdefghij

5 

6from typer.testing import CliRunner 1abcdefghij

7 

8from docs_src.launch import tutorial002 as mod 1abcdefghij

9 

10runner = CliRunner() 1abcdefghij

11 

12 

13def test_cli(app_dir: Path): 1abcdefghij

14 with patch("typer.launch") as launch_mock: 1abcdefghij

15 result = runner.invoke(mod.app) 1abcdefghij

16 

17 assert result.exit_code == 0 1abcdefghij

18 assert "Opening config directory" in result.output 1abcdefghij

19 launch_mock.assert_called_with(str(app_dir / "config.json"), locate=True) 1abcdefghij

20 

21 

22def test_script(): 1abcdefghij

23 result = subprocess.run( 1abcdefghij

24 [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], 

25 capture_output=True, 

26 encoding="utf-8", 

27 ) 

28 assert "Usage" in result.stdout 1abcdefghij