Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
test(cli): fix type annotations for mock dispatch callbacks
  • Loading branch information
mhaye9545 committed Sep 3, 2026
commit f9ba5c63cba7c05653b4faed4c0a5285d23d7cac
19 changes: 16 additions & 3 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,28 @@ def test_main_subcommands_dispatch(monkeypatch: pytest.MonkeyPatch, tmp_path: Pa
from gcmon.cli import main as cli

calls: list[str] = []
monkeypatch.setattr("gcmon.cli.commands.monitor_cmd.cmd_monitor", lambda args: calls.append("monitor") or 0)

def mock_monitor(args: object) -> int:
calls.append("monitor")
return 0

def mock_run(args: object) -> int:
calls.append("run")
return 0

def mock_combine(args: object) -> int:
calls.append("combine")
return 0

monkeypatch.setattr("gcmon.cli.commands.monitor_cmd.cmd_monitor", mock_monitor)
assert cli.main(["monitor", "12345"]) == 0
assert calls == ["monitor"]

monkeypatch.setattr("gcmon.cli.commands.run_cmd.cmd_run", lambda args: calls.append("run") or 0)
monkeypatch.setattr("gcmon.cli.commands.run_cmd.cmd_run", mock_run)
assert cli.main(["run", "-m", "timeit"]) == 0
assert calls == ["monitor", "run"]

monkeypatch.setattr("gcmon.cli.commands.convert_cmd.cmd_combine", lambda args: calls.append("combine") or 0)
monkeypatch.setattr("gcmon.cli.commands.convert_cmd.cmd_combine", mock_combine)
assert cli.main(["combine", str(tmp_path / "in.jsonl"), "-o", str(tmp_path / "out.pftrace")]) == 0
assert calls == ["monitor", "run", "combine"]

Expand Down