Skip to content
Myr

utils.py

This file

Path

tests/utils.py

52 lines · 1.6 KiB · Python

Last changed by

➖ Vendor Click and streamline Typer's functionality and code base (#1774)Sofie Van Landeghembefore adoption1829d73

History of this file

Take it

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

⬆ Bump prek from 0.3.6 to 0.3.8 (#1648)dependabot[bot]before adoptiond29528c

lines 1–11why, one step back
1import re
2import sys3from os import getenv45import pytest6from typer._completion_shared import _get_shell_name7from typer.core import HAS_RICH89needs_linux = pytest.mark.skipif(10 not sys.platform.startswith("linux"), reason="Test requires Linux"11)

➖ Vendor Click and streamline Typer's functionality and code base (#1774)Sofie Van Landeghembefore adoption1829d73

lines 12–14why, one step back
12needs_macos = pytest.mark.skipif(
13 not sys.platform.startswith("darwin"), reason="Test requires macOS"14)

🐛 Ensure that `typer.launch` forwards correctly when launching a file (#1708)Sofie Van Landeghembefore adoption31b468b

lines 15–16why, one step back
15needs_windows = pytest.mark.skipif(
16 not sys.platform.startswith("win"), reason="Test requires Windows"

➖ Vendor Click and streamline Typer's functionality and code base (#1774)Sofie Van Landeghembefore adoption1829d73

lines 17–20why, one step back
17)
18skip_if_windows = pytest.mark.skipif(19 sys.platform == "win32",20 reason="Test should not be run on Windows",

🐛 Ensure that `typer.launch` forwards correctly when launching a file (#1708)Sofie Van Landeghembefore adoption31b468b

line 21why, one step back
21)

⬆ Bump prek from 0.3.6 to 0.3.8 (#1648)dependabot[bot]before adoptiond29528c

lines 22–52why, one step back
22
23needs_rich = pytest.mark.skipif(not HAS_RICH, reason="Test requires Rich")2425shell = _get_shell_name()26needs_bash = pytest.mark.skipif(27 shell is None or "bash" not in shell, reason="Test requires Bash"28)2930requires_completion_permission = pytest.mark.skipif(31 not getenv("_TYPER_RUN_INSTALL_COMPLETION_TESTS", False),32 reason="Test requires permission to run completion installation tests",33)343536def strip_double_spaces(text: str) -> str:37 return re.sub(r" {2,}", " ", text)383940def normalize_rich_output(41 text: str, replace_with: str = "*", squash_whitespaces: bool = True42) -> str:43 """44 Replace all rich formatting characters with a simple placeholder.45 """46 text = re.sub(r"\x1b\[[0-9;]*m", replace_with, text)47 text = re.sub(r"[\u2500-\u257F]", replace_with, text)48 text = re.sub(r"[\U0001F300-\U0001F6FF]", replace_with, text)49 text = re.sub(f"{re.escape(replace_with)}+", replace_with, text)50 if squash_whitespaces:51 text = strip_double_spaces(text)52 return text