Coverage for tests/test_tutorial/test_multiple_values/test_arguments_with_multiple_values/test_tutorial001.py: 100%

16 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-09-09 18:26 +0000

1import subprocess 1abcdefgh

2import sys 1abcdefgh

3 

4import typer 1abcdefgh

5from typer.testing import CliRunner 1abcdefgh

6 

7from docs_src.multiple_values.arguments_with_multiple_values import tutorial001 as mod 1abcdefgh

8 

9runner = CliRunner() 1abcdefgh

10app = typer.Typer() 1abcdefgh

11app.command()(mod.main) 1abcdefgh

12 

13 

14def test_main(): 1abcdefgh

15 result = runner.invoke(app, ["README.md", "pyproject.toml", "woohoo!"]) 1abcdefgh

16 assert result.exit_code == 0 1abcdefgh

17 assert "This file exists: README.md\nwoohoo!" in result.output 1abcdefgh

18 assert "This file exists: pyproject.toml\nwoohoo!" in result.output 1abcdefgh

19 

20 

21def test_script(): 1abcdefgh

22 result = subprocess.run( 1abcdefgh

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

24 capture_output=True, 

25 encoding="utf-8", 

26 ) 

27 assert "Usage" in result.stdout 1abcdefgh