utils.py
This file
Path
tests/utils.py
46 lines · 1.3 KiB · Python
Last changed by
🐛 Fix highlighting of optional variadic argument metavars (#1508)Benjy Wienerbefore adoptiona2215eb
History of this fileTake it
The walk stopped after 200 commits: lines older than e0ca377 point at it.
✅ Add missing tests for code examples (#1465)Motov Yuriibefore adoption75bf405
line 1why, one step back1import re⬆ Bump mkdocs-material from 9.6.21 to 9.6.22 (#1377)dependabot[bot]before adoptione0ca377
lines 2–5why, one step back2import sys3from os import getenv45import pytest♻️ Refactor the handling of `shellingham` (#1347)Nathan McDougallbefore adoptionfd4241f
line 6why, one step back6from typer._completion_shared import _get_shell_name🐛 Fix highlighting of optional variadic argument metavars (#1508)Benjy Wienerbefore adoptiona2215eb
line 7why, one step back7from typer.core import HAS_RICH⬆ Bump mkdocs-material from 9.6.21 to 9.6.22 (#1377)dependabot[bot]before adoptione0ca377
lines 8–15why, one step back89needs_py310 = pytest.mark.skipif(10 sys.version_info < (3, 10), reason="requires python3.10+"11)1213needs_linux = pytest.mark.skipif(14 not sys.platform.startswith("linux"), reason="Test requires Linux"15)🐛 Fix highlighting of optional variadic argument metavars (#1508)Benjy Wienerbefore adoptiona2215eb
lines 16–17why, one step back1617needs_rich = pytest.mark.skipif(not HAS_RICH, reason="Test requires Rich")⬆ Bump mkdocs-material from 9.6.21 to 9.6.22 (#1377)dependabot[bot]before adoptione0ca377
line 18why, one step back18♻️ Refactor the handling of `shellingham` (#1347)Nathan McDougallbefore adoptionfd4241f
line 19why, one step back19shell = _get_shell_name()⬆ Bump mkdocs-material from 9.6.21 to 9.6.22 (#1377)dependabot[bot]before adoptione0ca377
line 20why, one step back20needs_bash = pytest.mark.skipif(♻️ Refactor the handling of `shellingham` (#1347)Nathan McDougallbefore adoptionfd4241f
line 21why, one step back21 shell is None or "bash" not in shell, reason="Test requires Bash"⬆ Bump mkdocs-material from 9.6.21 to 9.6.22 (#1377)dependabot[bot]before adoptione0ca377
lines 22–27why, one step back22)2324requires_completion_permission = pytest.mark.skipif(25 not getenv("_TYPER_RUN_INSTALL_COMPLETION_TESTS", False),26 reason="Test requires permission to run completion installation tests",27)✅ Add missing tests for code examples (#1465)Motov Yuriibefore adoption75bf405
lines 28–46why, one step back282930def strip_double_spaces(text: str) -> str:31 return re.sub(r" {2,}", " ", text)323334def normalize_rich_output(35 text: str, replace_with: str = "*", squash_whitespaces: bool = True36) -> str:37 """38 Replace all rich formatting characters with a simple placeholder.39 """40 text = re.sub(r"\x1b\[[0-9;]*m", replace_with, text)41 text = re.sub(r"[\u2500-\u257F]", replace_with, text)42 text = re.sub(r"[\U0001F300-\U0001F6FF]", replace_with, text)43 text = re.sub(f"{re.escape(replace_with)}+", replace_with, text)44 if squash_whitespaces:45 text = strip_double_spaces(text)46 return text