Skip to content
Myr

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 file

Take it

The walk stopped after 200 commits: lines older than 9930495 point at it.

⬆ [pre-commit.ci] pre-commit autoupdate (#592)pre-commit-ci[bot]before adoption9930495

lines 1–10why, one step back
1import os
2import 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 back
11 capture_output=True,

⬆ [pre-commit.ci] pre-commit autoupdate (#592)pre-commit-ci[bot]before adoption9930495

lines 12–18why, one step back
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.stderr

🔥 Remove support for Python 3.6 (#758)Sebastián Ramírezbefore adoption13404a0

line 19why, one step back
19 assert 'TypeError: can only concatenate str (not "int") to str' in result.stderr

⬆ [pre-commit.ci] pre-commit autoupdate (#592)pre-commit-ci[bot]before adoption9930495

lines 20–25why, one step back
20
2122def 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 back
26 capture_output=True,

⬆ [pre-commit.ci] pre-commit autoupdate (#592)pre-commit-ci[bot]before adoption9930495

lines 27–33why, one step back
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.stderr

🔥 Remove support for Python 3.6 (#758)Sebastián Ramírezbefore adoption13404a0

line 34why, one step back
34 assert 'TypeError: can only concatenate str (not "int") to str' in result.stderr

⬆ [pre-commit.ci] pre-commit autoupdate (#592)pre-commit-ci[bot]before adoption9930495

lines 35–40why, one step back
35
3637def 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 back
41 capture_output=True,

⬆ [pre-commit.ci] pre-commit autoupdate (#592)pre-commit-ci[bot]before adoption9930495

lines 42–51why, one step back
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.stderr

🔥 Remove support for Python 3.6 (#758)Sebastián Ramírezbefore adoption13404a0

line 52why, one step back
52 assert 'TypeError: can only concatenate str (not "int") to str' in result.stderr