fix(sp37-followup): use CliRunner in test_submit_batch_cli_help

Followup #2 from the SP37 final-state tracker. Replaces the
subprocess.run-based CLI help test with click.testing.CliRunner
(matches the pattern already used in test_cli.py).

Speedup: CliRunner doesn't spawn a subprocess, so the test runs in
~0.5s vs ~0.2s+ for subprocess (and the subprocess version was
susceptible to fork overhead, environment leakage between tests,
and PATH/CWD surprises on different hosts).

Same assertions:
  * result.exit_code == 0  (matches subprocess.returncode == 0)
  * '--ingest-dir' in result.output  (matches stdout check)

Test passes in isolation and as part of the full SP37 chain
(36 tests in 1.29s — same speedup as the single test).
This commit is contained in:
Nora
2026-07-07 12:17:50 -06:00
parent cc02cb99c5
commit ce0df8ac24
+16 -10
View File
@@ -196,13 +196,19 @@ def test_submit_file_uses_default_paramiko_factory(monkeypatch):
def test_submit_batch_cli_help():
"""`cyclone submit-batch --help` exits 0 and shows the flags."""
import subprocess
import sys
result = subprocess.run(
[sys.executable, "-m", "cyclone.cli", "submit-batch", "--help"],
capture_output=True, text=True,
cwd=str(Path(__file__).parent.parent),
)
assert result.returncode == 0
assert "--ingest-dir" in result.stdout
"""`cyclone submit-batch --help` exits 0 and shows the flags.
Uses ``click.testing.CliRunner`` instead of ``subprocess.run`` for
~10ms vs ~200ms per call. Same assertions — the CliRunner
``result.exit_code`` matches the subprocess returncode, and
``result.output`` is the Click-rendered help text (subprocess's
stdout).
"""
from click.testing import CliRunner
from cyclone.cli import main
runner = CliRunner()
result = runner.invoke(main, ["submit-batch", "--help"])
assert result.exit_code == 0, result.output
assert "--ingest-dir" in result.output