test_tracebacks.py
This file
Path
tests/test_tracebacks.py
52 lines · 2.0 KiB · Python
Last changed by
Not known.
History of this fileTake it
The walk stopped after 200 commits: lines older than 5b2a27d point at it.
📝 Update release notesgithub-actionsbefore adoption5b2a27d
lines 1–52why, one step back1import os2import subprocess3import sys4from pathlib import Path567def test_traceback_no_rich():8 file_path = Path(__file__).parent / "assets/type_error_no_rich.py"9 result = subprocess.run(10 [sys.executable, "-m", "coverage", "run", str(file_path)],11 capture_output=True,12 encoding="utf-8",13 env={**os.environ, "_TYPER_STANDARD_TRACEBACK": ""},14 )15 assert "return get_command(self)(*args, **kwargs)" not in result.stderr1617 assert "typer.run(main)" in result.stderr18 assert "print(name + 3)" in result.stderr19 assert 'TypeError: can only concatenate str (not "int") to str' in result.stderr202122def test_traceback_no_rich_short_disable():23 file_path = Path(__file__).parent / "assets/type_error_no_rich_short_disable.py"24 result = subprocess.run(25 [sys.executable, "-m", "coverage", "run", str(file_path)],26 capture_output=True,27 encoding="utf-8",28 env={**os.environ, "_TYPER_STANDARD_TRACEBACK": ""},29 )30 assert "return get_command(self)(*args, **kwargs)" not in result.stderr3132 assert "app()" in result.stderr33 assert "print(name + 3)" in result.stderr34 assert 'TypeError: can only concatenate str (not "int") to str' in result.stderr353637def test_unmodified_traceback():38 file_path = Path(__file__).parent / "assets/type_error_normal_traceback.py"39 result = subprocess.run(40 [sys.executable, "-m", "coverage", "run", str(file_path)],41 capture_output=True,42 encoding="utf-8",43 env={**os.environ, "_TYPER_STANDARD_TRACEBACK": ""},44 )45 assert "morty" in result.stdout, "the call to the first app should work normally"46 assert "return callback(**use_params)" in result.stderr, (47 "calling outside of Typer should show the normal traceback, "48 "even after the hook is installed"49 )50 assert "typer.main.get_command(broken_app)()" in result.stderr51 assert "print(name + 3)" in result.stderr52 assert 'TypeError: can only concatenate str (not "int") to str' in result.stderr