Skip to content
Myr

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 file

Take it

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

✅ Add missing tests for code examples (#1465)Motov Yuriibefore adoption75bf405

line 1why, one step back
1import re

📝 Update release notesgithub-actions[bot]before adoption96b418b

lines 2–5why, one step back
2import sys
3from os import getenv45import pytest

♻️ Refactor the handling of `shellingham` (#1347)Nathan McDougallbefore adoptionfd4241f

line 6why, one step back
6from typer._completion_shared import _get_shell_name

🐛 Fix highlighting of optional variadic argument metavars (#1508)Benjy Wienerbefore adoptiona2215eb

line 7why, one step back
7from typer.core import HAS_RICH

📝 Update release notesgithub-actions[bot]before adoption96b418b

lines 8–15why, one step back
8
9needs_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 back
16
17needs_rich = pytest.mark.skipif(not HAS_RICH, reason="Test requires Rich")

📝 Update release notesgithub-actions[bot]before adoption96b418b

line 18why, one step back
18

♻️ Refactor the handling of `shellingham` (#1347)Nathan McDougallbefore adoptionfd4241f

line 19why, one step back
19shell = _get_shell_name()

📝 Update release notesgithub-actions[bot]before adoption96b418b

line 20why, one step back
20needs_bash = pytest.mark.skipif(

♻️ Refactor the handling of `shellingham` (#1347)Nathan McDougallbefore adoptionfd4241f

line 21why, one step back
21 shell is None or "bash" not in shell, reason="Test requires Bash"

📝 Update release notesgithub-actions[bot]before adoption96b418b

lines 22–27why, one step back
22)
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 back
28
2930def 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