Coverage for tests / test_tutorial / test_exceptions / test_tutorial004.py: 100%

17 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-03-26 21:46 +0000

1import os 1abcdefg

2import subprocess 1abcdefg

3import sys 1abcdefg

4from pathlib import Path 1abcdefg

5 

6from typer.testing import CliRunner 1abcdefg

7 

8from docs_src.exceptions import tutorial004_py310 as mod 1abcdefg

9 

10runner = CliRunner() 1abcdefg

11 

12 

13def test_rich_pretty_exceptions_disable(): 1abcdefg

14 file_path = Path(mod.__file__) 1abcdefg

15 result = subprocess.run( 1abcdefg

16 [sys.executable, "-m", "coverage", "run", str(file_path)], 

17 capture_output=True, 

18 encoding="utf-8", 

19 env={ 

20 **os.environ, 

21 "TYPER_STANDARD_TRACEBACK": "", 

22 "_TYPER_STANDARD_TRACEBACK": "", 

23 }, 

24 ) 

25 assert "return get_command(self)(*args, **kwargs)" in result.stderr 1abcdefg

26 

27 assert "app()" in result.stderr 1abcdefg

28 assert "print(name + 3)" in result.stderr 1abcdefg

29 assert 'TypeError: can only concatenate str (not "int") to str' in result.stderr 1abcdefg

30 

31 

32def test_script(): 1abcdefg

33 result = subprocess.run( 1abcdefg

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

35 capture_output=True, 

36 encoding="utf-8", 

37 ) 

38 assert "Usage" in result.stdout 1abcdefg