Skip to content
Myr

utils.py

This file

Path

tests/utils.py

42 lines · 1.2 KiB · Python

Last changed by

➖ Drop support for Python 3.9 (#1546)Sebastián Ramírezbefore adoption28035df

History of this file

Take it

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

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

line 1why, one step back
1import re

⬆ Bump mkdocs-macros-plugin from 1.4.1 to 1.5.0 (#1406)dependabot[bot]before adoption1c58a0e

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

⬆ Bump mkdocs-macros-plugin from 1.4.1 to 1.5.0 (#1406)dependabot[bot]before adoption1c58a0e

lines 8–11why, one step back
8
9needs_linux = pytest.mark.skipif(10 not sys.platform.startswith("linux"), reason="Test requires Linux"11)

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

lines 12–13why, one step back
12
13needs_rich = pytest.mark.skipif(not HAS_RICH, reason="Test requires Rich")

⬆ Bump mkdocs-macros-plugin from 1.4.1 to 1.5.0 (#1406)dependabot[bot]before adoption1c58a0e

line 14why, one step back
14

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

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

⬆ Bump mkdocs-macros-plugin from 1.4.1 to 1.5.0 (#1406)dependabot[bot]before adoption1c58a0e

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

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

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

⬆ Bump mkdocs-macros-plugin from 1.4.1 to 1.5.0 (#1406)dependabot[bot]before adoption1c58a0e

lines 18–23why, one step back
18)
1920requires_completion_permission = pytest.mark.skipif(21 not getenv("_TYPER_RUN_INSTALL_COMPLETION_TESTS", False),22 reason="Test requires permission to run completion installation tests",23)

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

lines 24–42why, one step back
24
2526def strip_double_spaces(text: str) -> str:27 return re.sub(r" {2,}", " ", text)282930def normalize_rich_output(31 text: str, replace_with: str = "*", squash_whitespaces: bool = True32) -> str:33 """34 Replace all rich formatting characters with a simple placeholder.35 """36 text = re.sub(r"\x1b\[[0-9;]*m", replace_with, text)37 text = re.sub(r"[\u2500-\u257F]", replace_with, text)38 text = re.sub(r"[\U0001F300-\U0001F6FF]", replace_with, text)39 text = re.sub(f"{re.escape(replace_with)}+", replace_with, text)40 if squash_whitespaces:41 text = strip_double_spaces(text)42 return text