Coverage for tests / test_completion / test_sanitization.py: 100%
9 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-03-26 21:46 +0000
« prev ^ index » next coverage.py v7.13.1, created at 2026-03-26 21:46 +0000
1from importlib.machinery import ModuleSpec 1abcdefg
2from unittest.mock import patch 1abcdefg
4import pytest 1abcdefg
5from typer._completion_classes import _sanitize_help_text 1abcdefg
8@pytest.mark.parametrize( 1abcdefg
9 "find_spec, help_text, expected",
10 [
11 (
12 ModuleSpec("rich", loader=None),
13 "help text without rich tags",
14 "help text without rich tags",
15 ),
16 (
17 None,
18 "help text without rich tags",
19 "help text without rich tags",
20 ),
21 (
22 ModuleSpec("rich", loader=None),
23 "help [bold]with[/] rich tags",
24 "help with rich tags",
25 ),
26 (
27 None,
28 "help [bold]with[/] rich tags",
29 "help [bold]with[/] rich tags",
30 ),
31 ],
32)
33def test_sanitize_help_text( 1abcdefg
34 find_spec: ModuleSpec | None, help_text: str, expected: str
35):
36 with patch("importlib.util.find_spec", return_value=find_spec) as mock_find_spec: 1abcdefg
37 assert _sanitize_help_text(help_text) == expected 1abcdefg
38 mock_find_spec.assert_called_once_with("rich") 1abcdefg