Skip to content

Commit d9a00e1

Browse files
committed
tests(cli/help_examples): Add integration tests for colorized examples
Add integration tests to verify: - Main --help has section headings with "examples:" suffix - Example sections are colorized when FORCE_COLOR is set Also update comment to reflect the new heading format.
1 parent 9e98012 commit d9a00e1

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

tests/cli/test_help_examples.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def extract_examples_from_help(help_text: str) -> list[str]:
7171
for line in help_text.splitlines():
7272
# Match example section headings:
7373
# - "examples:" (default examples section)
74-
# - "load examples:" or "load:" (category headings)
74+
# - "load examples:" (category headings with examples suffix)
7575
# - "Field-scoped search:" (multi-word category headings)
7676
# Exclude argparse sections like "positional arguments:", "options:"
7777
stripped = line.strip()
@@ -250,3 +250,24 @@ def test_search_no_args_shows_help() -> None:
250250
assert "usage: tmuxp search" in result.stdout
251251
# Should exit successfully (not error)
252252
assert result.returncode == 0
253+
254+
255+
def test_main_help_example_sections_have_examples_suffix() -> None:
256+
"""Main --help should have section headings ending with 'examples:'."""
257+
help_text = _get_help_text()
258+
259+
# Should have "load examples:", "freeze examples:", etc.
260+
# NOT just "load:", "freeze:"
261+
assert "load examples:" in help_text.lower()
262+
assert "freeze examples:" in help_text.lower()
263+
264+
265+
def test_main_help_examples_are_colorized(monkeypatch: pytest.MonkeyPatch) -> None:
266+
"""Main --help should have colorized example sections when FORCE_COLOR is set."""
267+
monkeypatch.delenv("NO_COLOR", raising=False)
268+
monkeypatch.setenv("FORCE_COLOR", "1")
269+
270+
help_text = _get_help_text()
271+
272+
# Should contain ANSI escape codes for colorization
273+
assert "\033[" in help_text, "Example sections should be colorized"

0 commit comments

Comments
 (0)