test_tracebacks.py
This file
Path
tests/test_tracebacks.py
55 lines · 2.1 KiB · Python
Last changed by
🔥 Remove support for Python 3.6 (#758)Sebastián Ramírezbefore adoption13404a0
History of this fileTake it
✨ Richify, add integrations with Rich everywhere (#419)Sebastián Ramírezbefore adoption6208b5b
line 1why, one step back1import os✨ Add pretty error tracebacks for user errors and support for Rich (#412)Sebastián Ramírezbefore adoption252ed30
line 2why, one step back2import subprocess👷♂️ Consistently use `sys.executable` to run subprocesses, needed by OpenSUSE (#408)Matthias Bachbefore adoption416c612
line 3why, one step back3import sys✨ Add pretty error tracebacks for user errors and support for Rich (#412)Sebastián Ramírezbefore adoption252ed30
lines 4–9why, one step back4from pathlib import Path567def test_traceback_no_rich():8 file_path = Path(__file__).parent / "assets/type_error_no_rich.py"9 result = subprocess.run(👷♂️ Consistently use `sys.executable` to run subprocesses, needed by OpenSUSE (#408)Matthias Bachbefore adoption416c612
line 10why, one step back10 [sys.executable, "-m", "coverage", "run", str(file_path)],✨ Add pretty error tracebacks for user errors and support for Rich (#412)Sebastián Ramírezbefore adoption252ed30
lines 11–13why, one step back11 stdout=subprocess.PIPE,12 stderr=subprocess.PIPE,13 encoding="utf-8",✨ Richify, add integrations with Rich everywhere (#419)Sebastián Ramírezbefore adoption6208b5b
line 14why, one step back14 env={**os.environ, "_TYPER_STANDARD_TRACEBACK": ""},✨ Add pretty error tracebacks for user errors and support for Rich (#412)Sebastián Ramírezbefore adoption252ed30
lines 15–19why, one step back15 )16 assert "return get_command(self)(*args, **kwargs)" not in result.stderr1718 assert "typer.run(main)" in result.stderr19 assert "print(name + 3)" in result.stderr🔥 Remove support for Python 3.6 (#758)Sebastián Ramírezbefore adoption13404a0
line 20why, one step back20 assert 'TypeError: can only concatenate str (not "int") to str' in result.stderr✨ Add pretty error tracebacks for user errors and support for Rich (#412)Sebastián Ramírezbefore adoption252ed30
lines 21–22why, one step back2122✨ Allow configuring pretty errors when creating the Typer instance (#416)Sebastián Ramírezbefore adoption95a5233
lines 23–25why, one step back23def test_traceback_no_rich_short_disable():24 file_path = Path(__file__).parent / "assets/type_error_no_rich_short_disable.py"25 result = subprocess.run(👷♂️ Consistently use `sys.executable` to run subprocesses, needed by OpenSUSE (#408)Matthias Bachbefore adoption416c612
line 26why, one step back26 [sys.executable, "-m", "coverage", "run", str(file_path)],✨ Allow configuring pretty errors when creating the Typer instance (#416)Sebastián Ramírezbefore adoption95a5233
lines 27–29why, one step back27 stdout=subprocess.PIPE,28 stderr=subprocess.PIPE,29 encoding="utf-8",✨ Richify, add integrations with Rich everywhere (#419)Sebastián Ramírezbefore adoption6208b5b
line 30why, one step back30 env={**os.environ, "_TYPER_STANDARD_TRACEBACK": ""},✨ Allow configuring pretty errors when creating the Typer instance (#416)Sebastián Ramírezbefore adoption95a5233
lines 31–35why, one step back31 )32 assert "return get_command(self)(*args, **kwargs)" not in result.stderr3334 assert "app()" in result.stderr35 assert "print(name + 3)" in result.stderr🔥 Remove support for Python 3.6 (#758)Sebastián Ramírezbefore adoption13404a0
line 36why, one step back36 assert 'TypeError: can only concatenate str (not "int") to str' in result.stderr✨ Allow configuring pretty errors when creating the Typer instance (#416)Sebastián Ramírezbefore adoption95a5233
lines 37–38why, one step back3738✨ Add pretty error tracebacks for user errors and support for Rich (#412)Sebastián Ramírezbefore adoption252ed30
lines 39–41why, one step back39def test_unmodified_traceback():40 file_path = Path(__file__).parent / "assets/type_error_normal_traceback.py"41 result = subprocess.run(👷♂️ Consistently use `sys.executable` to run subprocesses, needed by OpenSUSE (#408)Matthias Bachbefore adoption416c612
line 42why, one step back42 [sys.executable, "-m", "coverage", "run", str(file_path)],✨ Add pretty error tracebacks for user errors and support for Rich (#412)Sebastián Ramírezbefore adoption252ed30
lines 43–45why, one step back43 stdout=subprocess.PIPE,44 stderr=subprocess.PIPE,45 encoding="utf-8",✨ Richify, add integrations with Rich everywhere (#419)Sebastián Ramírezbefore adoption6208b5b
line 46why, one step back46 env={**os.environ, "_TYPER_STANDARD_TRACEBACK": ""},✨ Add pretty error tracebacks for user errors and support for Rich (#412)Sebastián Ramírezbefore adoption252ed30
lines 47–54why, one step back47 )48 assert "morty" in result.stdout, "the call to the first app should work normally"49 assert "return callback(**use_params)" in result.stderr, (50 "calling outside of Typer should show the normal traceback, "51 "even after the hook is installed"52 )53 assert "typer.main.get_command(broken_app)()" in result.stderr54 assert "print(name + 3)" in result.stderr🔥 Remove support for Python 3.6 (#758)Sebastián Ramírezbefore adoption13404a0
line 55why, one step back55 assert 'TypeError: can only concatenate str (not "int") to str' in result.stderr