test_tracebacks.py
This file
Path
tests/test_tracebacks.py
52 lines · 2.0 KiB · Python
Last changed by
🔧 Migrate from Black, isort, flake8, autoflake, pyupgrade to Ruff (#763)Sebastián Ramírezbefore adoption38b8e4a
History of this fileTake it
The walk stopped after 200 commits: lines older than d6921fb point at it.
📝 Update release notesgithub-actionsbefore adoptiond6921fb
lines 1–10why, 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)],🔧 Migrate from Black, isort, flake8, autoflake, pyupgrade to Ruff (#763)Sebastián Ramírezbefore adoption38b8e4a
line 11why, one step back11 capture_output=True,📝 Update release notesgithub-actionsbefore adoptiond6921fb
lines 12–25why, one step back12 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)],🔧 Migrate from Black, isort, flake8, autoflake, pyupgrade to Ruff (#763)Sebastián Ramírezbefore adoption38b8e4a
line 26why, one step back26 capture_output=True,📝 Update release notesgithub-actionsbefore adoptiond6921fb
lines 27–40why, one step back27 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)],🔧 Migrate from Black, isort, flake8, autoflake, pyupgrade to Ruff (#763)Sebastián Ramírezbefore adoption38b8e4a
line 41why, one step back41 capture_output=True,📝 Update release notesgithub-actionsbefore adoptiond6921fb
lines 42–52why, one step back42 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