Skip to content

Commit a0bc812

Browse files
authored
chore(cli): show sub-command help string in execute --help output (#1878)
* chore(cli): show sub-command help in `execute --help` output * chore(cli): make sub-command help strings good one-liners Previously: ``` Commands: hive Execute tests using hive in dev-mode as backend, requires hive... recover Recover funds from a failed test execution using a remote RPC... remote Execute tests using a remote RPC endpoint. ``` Now: ``` Commands: hive Execute tests using hive dev-mode as a backend (`./hive --dev`). recover Recover funds from test executions using a remote RPC endpoint. remote Execute tests using a remote RPC endpoint. ``` * test(execute): add framework tests for missing help
1 parent a2449bf commit a0bc812

File tree

2 files changed

+47
-6
lines changed

2 files changed

+47
-6
lines changed

src/cli/pytest_commands/execute.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ def _create_execute_subcommand(
2727

2828
@execute.command(
2929
name=command_name,
30+
help=help_text,
3031
context_settings={"ignore_unknown_options": True},
3132
)
3233
@common_pytest_options
33-
def command(pytest_args: List[str], **kwargs) -> None:
34+
def command(pytest_args: List[str], **_kwargs) -> None:
3435
pytest_command = PytestCommand(
3536
config_file=config_file,
3637
argument_processors=[HelpFlagsProcessor(f"execute-{command_name}")],
@@ -45,10 +46,7 @@ def command(pytest_args: List[str], **kwargs) -> None:
4546
hive = _create_execute_subcommand(
4647
"hive",
4748
"pytest-execute-hive.ini",
48-
(
49-
"Execute tests using hive in dev-mode as backend, requires hive to be running "
50-
"(using command: `./hive --dev`)."
51-
),
49+
"Execute tests using hive as a backend (`./hive --dev`).",
5250
)
5351

5452
remote = _create_execute_subcommand(
@@ -60,5 +58,5 @@ def command(pytest_args: List[str], **kwargs) -> None:
6058
recover = _create_execute_subcommand(
6159
"recover",
6260
"pytest-execute-recover.ini",
63-
"Recover funds from a failed test execution using a remote RPC endpoint.",
61+
"Recover funds from test executions using a remote RPC endpoint.",
6462
)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""Tests for execute command click CLI."""
2+
3+
import pytest
4+
from click.testing import CliRunner
5+
6+
from ..pytest_commands.execute import execute
7+
8+
9+
@pytest.fixture
10+
def runner():
11+
"""Provide a Click CliRunner for invoking command-line interfaces."""
12+
return CliRunner()
13+
14+
15+
def test_execute_help_shows_subcommand_docstrings(runner):
16+
"""Test that execute --help shows sub-command docstrings."""
17+
result = runner.invoke(execute, ["--help"])
18+
assert result.exit_code == 0
19+
20+
# Check that all sub-commands are shown with their help text
21+
assert "hive" in result.output
22+
assert "Execute tests using hive as a backend" in result.output
23+
24+
assert "remote" in result.output
25+
assert "Execute tests using a remote RPC endpoint" in result.output
26+
27+
assert "recover" in result.output
28+
assert "Recover funds from test executions" in result.output
29+
30+
31+
def test_execute_subcommands_have_help_text(runner):
32+
"""Test that execute sub-commands have proper help text defined."""
33+
from ..pytest_commands.execute import hive, recover, remote
34+
35+
# Test that each sub-command has a docstring
36+
assert hive.__doc__ is not None
37+
assert "hive" in hive.__doc__.lower()
38+
39+
assert remote.__doc__ is not None
40+
assert "remote" in remote.__doc__.lower()
41+
42+
assert recover.__doc__ is not None
43+
assert "recover" in recover.__doc__.lower()

0 commit comments

Comments
 (0)