"""Comprehensive tests for ``muse commit-graph``. Coverage tiers -------------- - Unit: _CommitNode schema, _DEFAULT_MAX - Integration: linear chain, --tip, --max, --count, --first-parent, --stop-at, --ancestry-path, text format, json shorthand - Security: errors to stderr, no traceback on bad tip - Stress: 50-commit chain traversal """ from __future__ import annotations import datetime import json import pathlib from muse.core.errors import ExitCode from muse.core.ids import hash_commit, hash_snapshot from muse.core.commits import ( CommitRecord, write_commit, ) from muse.core.snapshots import ( SnapshotRecord, write_snapshot, ) from tests.cli_test_helper import CliRunner, InvokeResult from muse.core.paths import muse_dir runner = CliRunner() _DT = datetime.datetime(2026, 1, 1, tzinfo=datetime.timezone.utc) # --------------------------------------------------------------------------- # Helpers # --------------------------------------------------------------------------- def _make_repo(tmp_path: pathlib.Path) -> pathlib.Path: repo = tmp_path / "repo" dot_muse = muse_dir(repo) for sub in ("objects", "commits", "snapshots", "refs/heads"): (dot_muse / sub).mkdir(parents=True) (dot_muse / "HEAD").write_text("ref: refs/heads/main") (dot_muse / "repo.json").write_text(json.dumps({"repo_id": "test-repo", "domain": "code"})) return repo def _snap(repo: pathlib.Path) -> str: """Write a snapshot with an empty manifest; return its content-addressed ID.""" sid = hash_snapshot({}) write_snapshot(repo, SnapshotRecord( snapshot_id=sid, manifest={}, created_at=_DT, )) return sid def _commit( repo: pathlib.Path, snap_id: str, *, parent: str | None = None, parent2: str | None = None, message: str = "test", ) -> str: """Write a commit with a real content-addressed ID; return the commit ID.""" parent_ids = [p for p in [parent, parent2] if p is not None] commit_id = hash_commit( parent_ids=parent_ids, snapshot_id=snap_id, message=message, committed_at_iso=_DT.isoformat(), ) write_commit(repo, CommitRecord( commit_id=commit_id, branch="main", snapshot_id=snap_id, message=message, committed_at=_DT, parent_commit_id=parent, parent2_commit_id=parent2, )) return commit_id def _set_head(repo: pathlib.Path, branch: str, commit_id: str) -> None: ref = ref_path(repo, branch) ref.parent.mkdir(parents=True, exist_ok=True) ref.write_text(commit_id) (head_path(repo)).write_text(f"ref: refs/heads/{branch}") def _cg(repo: pathlib.Path, *args: str) -> InvokeResult: from muse.cli.app import main as cli return runner.invoke( cli, ["commit-graph", "--json", *args], env={"MUSE_REPO_ROOT": str(repo)}, ) # --------------------------------------------------------------------------- # Unit # --------------------------------------------------------------------------- class TestUnit: def test_commit_node_fields(self) -> None: from muse.cli.commands.commit_graph import _CommitNode fields = set(_CommitNode.__annotations__.keys()) assert "commit_id" in fields assert "parent_commit_id" in fields assert "parent2_commit_id" in fields assert "message" in fields assert "snapshot_id" in fields assert "branch" in fields assert "committed_at" in fields assert "author" in fields def test_default_max(self) -> None: from muse.cli.commands.commit_graph import _DEFAULT_MAX assert _DEFAULT_MAX >= 1000 def test_ancestors_of_single_commit(self, tmp_path: pathlib.Path) -> None: from muse.cli.commands.commit_graph import _ancestors_of repo = _make_repo(tmp_path) snap_id = _snap(repo) cid = _commit(repo, snap_id) result = _ancestors_of(repo, cid) assert cid in result def test_ancestors_of_linear_chain(self, tmp_path: pathlib.Path) -> None: from muse.cli.commands.commit_graph import _ancestors_of repo = _make_repo(tmp_path) snap_id = _snap(repo) c1 = _commit(repo, snap_id, message="c1") c2 = _commit(repo, snap_id, parent=c1, message="c2") c3 = _commit(repo, snap_id, parent=c2, message="c3") result = _ancestors_of(repo, c3) assert c1 in result assert c2 in result assert c3 in result def test_ancestors_of_merge_commit_follows_both_parents(self, tmp_path: pathlib.Path) -> None: from muse.cli.commands.commit_graph import _ancestors_of repo = _make_repo(tmp_path) snap_id = _snap(repo) base = _commit(repo, snap_id, message="base") left = _commit(repo, snap_id, parent=base, message="left") right = _commit(repo, snap_id, parent=base, message="right") merge = _commit(repo, snap_id, parent=left, parent2=right, message="merge") result = _ancestors_of(repo, merge) assert base in result assert left in result assert right in result assert merge in result def test_ancestors_of_missing_commit_returns_empty(self, tmp_path: pathlib.Path) -> None: from muse.cli.commands.commit_graph import _ancestors_of from muse.core.types import blob_id repo = _make_repo(tmp_path) # Use blob_id to produce a well-formed sha256: ID that doesn't exist as a commit. missing = blob_id(b"this commit does not exist") # Missing commit: read_commit returns None, so it is skipped → empty set. result = _ancestors_of(repo, missing) assert missing not in result assert len(result) == 0 # --------------------------------------------------------------------------- # Integration — JSON format # --------------------------------------------------------------------------- class TestJsonFormat: def test_linear_two_commits(self, tmp_path: pathlib.Path) -> None: repo = _make_repo(tmp_path) snap_id = _snap(repo) c1 = _commit(repo, snap_id, message="c1") c2 = _commit(repo, snap_id, parent=c1, message="c2") _set_head(repo, "main", c2) result = _cg(repo) assert result.exit_code == 0 data = json.loads(result.output) assert data["count"] == 2 ids = {c["commit_id"] for c in data["commits"]} assert {c1, c2} == ids def test_tip_is_present_in_output(self, tmp_path: pathlib.Path) -> None: repo = _make_repo(tmp_path) snap_id = _snap(repo) cid = _commit(repo, snap_id) _set_head(repo, "main", cid) data = json.loads(_cg(repo).output) assert data["tip"] == cid def test_explicit_tip(self, tmp_path: pathlib.Path) -> None: repo = _make_repo(tmp_path) snap_id = _snap(repo) cid = _commit(repo, snap_id) result = _cg(repo, "--tip", cid) assert result.exit_code == 0 data = json.loads(result.output) assert data["tip"] == cid def test_json_shorthand(self, tmp_path: pathlib.Path) -> None: repo = _make_repo(tmp_path) snap_id = _snap(repo) cid = _commit(repo, snap_id) _set_head(repo, "main", cid) result = _cg(repo, "--json") assert result.exit_code == 0 assert "commits" in json.loads(result.output) def test_truncated_flag_when_limited(self, tmp_path: pathlib.Path) -> None: repo = _make_repo(tmp_path) snap_id = _snap(repo) c1 = _commit(repo, snap_id, message="c1") c2 = _commit(repo, snap_id, parent=c1, message="c2") _set_head(repo, "main", c2) data = json.loads(_cg(repo, "--max", "1").output) assert data["truncated"] is True # --------------------------------------------------------------------------- # Integration — --count # --------------------------------------------------------------------------- class TestCountOnly: def test_count_returns_integer(self, tmp_path: pathlib.Path) -> None: repo = _make_repo(tmp_path) snap_id = _snap(repo) cid = _commit(repo, snap_id) _set_head(repo, "main", cid) data = json.loads(_cg(repo, "--count").output) assert data["count"] == 1 assert "commits" not in data def test_count_reflects_chain_length(self, tmp_path: pathlib.Path) -> None: repo = _make_repo(tmp_path) snap_id = _snap(repo) c1 = _commit(repo, snap_id, message="c1") c2 = _commit(repo, snap_id, parent=c1, message="c2") c3 = _commit(repo, snap_id, parent=c2, message="c3") _set_head(repo, "main", c3) data = json.loads(_cg(repo, "--count").output) assert data["count"] == 3 # --------------------------------------------------------------------------- # Integration — --first-parent # --------------------------------------------------------------------------- class TestFirstParent: def test_first_parent_skips_merge_parent(self, tmp_path: pathlib.Path) -> None: repo = _make_repo(tmp_path) snap_id = _snap(repo) p1 = _commit(repo, snap_id, message="p1") p2 = _commit(repo, snap_id, message="p2") merge = _commit(repo, snap_id, parent=p1, parent2=p2, message="merge") _set_head(repo, "main", merge) data = json.loads(_cg(repo, "--first-parent").output) ids = {c["commit_id"] for c in data["commits"]} assert p2 not in ids assert p1 in ids assert merge in ids # --------------------------------------------------------------------------- # Integration — --stop-at # --------------------------------------------------------------------------- class TestStopAt: def test_stop_at_excludes_old_commits(self, tmp_path: pathlib.Path) -> None: repo = _make_repo(tmp_path) snap_id = _snap(repo) c1 = _commit(repo, snap_id, message="c1") c2 = _commit(repo, snap_id, parent=c1, message="c2") c3 = _commit(repo, snap_id, parent=c2, message="c3") _set_head(repo, "main", c3) data = json.loads(_cg(repo, "--stop-at", c2).output) ids = {c["commit_id"] for c in data["commits"]} assert c2 not in ids assert c1 not in ids assert c3 in ids # --------------------------------------------------------------------------- # Integration — text format # --------------------------------------------------------------------------- class TestTextFormat: def test_text_one_id_per_line(self, tmp_path: pathlib.Path) -> None: repo = _make_repo(tmp_path) snap_id = _snap(repo) cid = _commit(repo, snap_id) _set_head(repo, "main", cid) from muse.cli.app import main as cli result = runner.invoke( cli, ["commit-graph"], env={"MUSE_REPO_ROOT": str(repo)}, ) assert result.exit_code == 0 assert cid in result.output # --------------------------------------------------------------------------- # Error cases # --------------------------------------------------------------------------- class TestErrors: def test_no_commits_errors(self, tmp_path: pathlib.Path) -> None: repo = _make_repo(tmp_path) result = _cg(repo) assert result.exit_code == ExitCode.USER_ERROR def test_tip_not_found_errors(self, tmp_path: pathlib.Path) -> None: repo = _make_repo(tmp_path) result = _cg(repo, "--tip", f"dead{'beef' * 15}") assert result.exit_code == ExitCode.USER_ERROR def test_ancestry_path_without_stop_at_errors(self, tmp_path: pathlib.Path) -> None: repo = _make_repo(tmp_path) snap_id = _snap(repo) cid = _commit(repo, snap_id) _set_head(repo, "main", cid) result = _cg(repo, "--ancestry-path") assert result.exit_code == ExitCode.USER_ERROR def test_no_traceback_on_bad_tip(self, tmp_path: pathlib.Path) -> None: repo = _make_repo(tmp_path) result = _cg(repo, "--tip", "bad") assert "Traceback" not in result.output # --------------------------------------------------------------------------- # Stress # --------------------------------------------------------------------------- class TestSecurity: def test_format_error_to_stderr(self, tmp_path: pathlib.Path) -> None: repo = _make_repo(tmp_path) r = _cg(repo, "--format", "xml") assert r.exit_code != 0 assert r.stdout_bytes == b"" assert "error" in r.stderr.lower() def test_no_traceback_on_bad_format(self, tmp_path: pathlib.Path) -> None: repo = _make_repo(tmp_path) r = _cg(repo, "--format", "bad") assert "Traceback" not in r.output assert "Traceback" not in r.stderr def test_ansi_in_tip_rejected_gracefully(self, tmp_path: pathlib.Path) -> None: """An ANSI-injected tip ID must not crash; it's not a valid commit.""" repo = _make_repo(tmp_path) r = _cg(repo, "--tip", "\x1b[31mbad\x1b[0m") assert "Traceback" not in r.output assert "Traceback" not in r.stderr def test_json_shorthand_flag(self, tmp_path: pathlib.Path) -> None: repo = _make_repo(tmp_path) snap_id = _snap(repo) cid = _commit(repo, snap_id) _set_head(repo, "main", cid) r = _cg(repo, "--json") assert r.exit_code == 0 d = json.loads(r.output) assert "commits" in d class TestStress: def test_50_commit_linear_chain(self, tmp_path: pathlib.Path) -> None: repo = _make_repo(tmp_path) snap_id = _snap(repo) prev: str | None = None for i in range(50): prev = _commit(repo, snap_id, parent=prev, message=f"commit {i}") assert prev is not None _set_head(repo, "main", prev) data = json.loads(_cg(repo, "--count").output) assert data["count"] == 50 def test_branching_dag_100_commits(self, tmp_path: pathlib.Path) -> None: """10-branch DAG — --ancestry-path + --first-parent should complete.""" repo = _make_repo(tmp_path) snap_id = _snap(repo) base = _commit(repo, snap_id, message="base") tips: list[str] = [] for i in range(10): tip = _commit(repo, snap_id, parent=base, message=f"branch {i}") tips.append(tip) merge = _commit(repo, snap_id, parent=tips[-1], parent2=tips[-2], message="merge") _set_head(repo, "main", merge) r = _cg(repo, "--json") assert r.exit_code == 0 d = json.loads(r.output) commit_ids = {c["commit_id"] for c in d["commits"]} assert merge in commit_ids assert base in commit_ids def test_200_sequential_calls(self, tmp_path: pathlib.Path) -> None: repo = _make_repo(tmp_path) snap_id = _snap(repo) cid = _commit(repo, snap_id) _set_head(repo, "main", cid) for i in range(200): r = _cg(repo) assert r.exit_code == 0, f"failed at {i}" # --------------------------------------------------------------------------- # Supercharge — duration_ms, exit_code, agent provenance in nodes # --------------------------------------------------------------------------- _FULL_TOP_KEYS = frozenset({"tip", "count", "truncated", "commits", "duration_ms", "exit_code"}) _FULL_COUNT_KEYS = frozenset({"tip", "count", "truncated", "duration_ms", "exit_code"}) _FULL_NODE_KEYS = frozenset({ "commit_id", "parent_commit_id", "parent2_commit_id", "message", "branch", "committed_at", "snapshot_id", "author", "agent_id", "model_id", "sem_ver_bump", "breaking_changes", }) def _commit_with_provenance( repo: pathlib.Path, snap_id: str, *, parent: str | None = None, message: str = "test", agent_id: str = "claude-code", model_id: str = "claude-sonnet-4-6", sem_ver_bump: str = "minor", ) -> str: """Write a commit with full agent provenance; return the commit ID.""" parent_ids = [parent] if parent else [] commit_id = hash_commit( parent_ids=parent_ids, snapshot_id=snap_id, message=message, committed_at_iso=_DT.isoformat(), ) write_commit(repo, CommitRecord( commit_id=commit_id, branch="main", snapshot_id=snap_id, message=message, committed_at=_DT, parent_commit_id=parent, agent_id=agent_id, model_id=model_id, sem_ver_bump=sem_ver_bump, breaking_changes=[], )) return commit_id class TestElapsed: """Every JSON output path must include ``duration_ms`` as a float.""" def test_full_json_has_elapsed(self, tmp_path: pathlib.Path) -> None: repo = _make_repo(tmp_path) snap_id = _snap(repo) cid = _commit(repo, snap_id) _set_head(repo, "main", cid) r = _cg(repo) assert r.exit_code == 0 data = json.loads(r.output) assert "duration_ms" in data, "duration_ms missing from full JSON" assert isinstance(data["duration_ms"], float) assert data["duration_ms"] >= 0.0 def test_count_only_has_elapsed(self, tmp_path: pathlib.Path) -> None: repo = _make_repo(tmp_path) snap_id = _snap(repo) cid = _commit(repo, snap_id) _set_head(repo, "main", cid) r = _cg(repo, "--count") assert r.exit_code == 0 data = json.loads(r.output) assert "duration_ms" in data, "duration_ms missing from --count JSON" assert isinstance(data["duration_ms"], float) def test_elapsed_is_non_negative(self, tmp_path: pathlib.Path) -> None: repo = _make_repo(tmp_path) snap_id = _snap(repo) cid = _commit(repo, snap_id) _set_head(repo, "main", cid) r = _cg(repo) data = json.loads(r.output) assert data["duration_ms"] >= 0.0 class TestExitCode: """Every JSON output path must include ``exit_code`` mirroring the process exit.""" def test_full_json_exit_code_0(self, tmp_path: pathlib.Path) -> None: repo = _make_repo(tmp_path) snap_id = _snap(repo) cid = _commit(repo, snap_id) _set_head(repo, "main", cid) r = _cg(repo) assert r.exit_code == 0 data = json.loads(r.output) assert data["exit_code"] == 0 def test_count_only_exit_code_0(self, tmp_path: pathlib.Path) -> None: repo = _make_repo(tmp_path) snap_id = _snap(repo) cid = _commit(repo, snap_id) _set_head(repo, "main", cid) r = _cg(repo, "--count") assert r.exit_code == 0 data = json.loads(r.output) assert data["exit_code"] == 0 class TestJsonSchemaComplete: """Full key-set present in both top-level and node objects.""" def test_top_level_keys_complete(self, tmp_path: pathlib.Path) -> None: repo = _make_repo(tmp_path) snap_id = _snap(repo) cid = _commit(repo, snap_id) _set_head(repo, "main", cid) r = _cg(repo) data = json.loads(r.output) missing = _FULL_TOP_KEYS - data.keys() assert not missing, f"Top-level JSON missing keys: {missing}" def test_count_keys_complete(self, tmp_path: pathlib.Path) -> None: repo = _make_repo(tmp_path) snap_id = _snap(repo) cid = _commit(repo, snap_id) _set_head(repo, "main", cid) r = _cg(repo, "--count") data = json.loads(r.output) missing = _FULL_COUNT_KEYS - data.keys() assert not missing, f"--count JSON missing keys: {missing}" def test_node_provenance_keys_complete(self, tmp_path: pathlib.Path) -> None: """Each commit node must expose agent_id, model_id, sem_ver_bump, breaking_changes.""" repo = _make_repo(tmp_path) snap_id = _snap(repo) cid = _commit_with_provenance(repo, snap_id) _set_head(repo, "main", cid) r = _cg(repo) data = json.loads(r.output) assert data["commits"], "Expected at least one node" node = data["commits"][0] missing = _FULL_NODE_KEYS - node.keys() assert not missing, f"Node missing keys: {missing}" class TestNodeProvenance: """agent_id, model_id, sem_ver_bump, breaking_changes are surfaced per node.""" def test_agent_id_in_node(self, tmp_path: pathlib.Path) -> None: repo = _make_repo(tmp_path) snap_id = _snap(repo) cid = _commit_with_provenance(repo, snap_id, agent_id="agentception/worker") _set_head(repo, "main", cid) r = _cg(repo) node = json.loads(r.output)["commits"][0] assert node["agent_id"] == "agentception/worker" def test_model_id_in_node(self, tmp_path: pathlib.Path) -> None: repo = _make_repo(tmp_path) snap_id = _snap(repo) cid = _commit_with_provenance(repo, snap_id, model_id="claude-opus-4-6") _set_head(repo, "main", cid) r = _cg(repo) node = json.loads(r.output)["commits"][0] assert node["model_id"] == "claude-opus-4-6" def test_sem_ver_bump_in_node(self, tmp_path: pathlib.Path) -> None: repo = _make_repo(tmp_path) snap_id = _snap(repo) cid = _commit_with_provenance(repo, snap_id, sem_ver_bump="major") _set_head(repo, "main", cid) r = _cg(repo) node = json.loads(r.output)["commits"][0] assert node["sem_ver_bump"] == "major" def test_breaking_changes_is_list(self, tmp_path: pathlib.Path) -> None: repo = _make_repo(tmp_path) snap_id = _snap(repo) cid = _commit_with_provenance(repo, snap_id) _set_head(repo, "main", cid) r = _cg(repo) node = json.loads(r.output)["commits"][0] assert isinstance(node["breaking_changes"], list) def test_human_commit_has_empty_agent_id(self, tmp_path: pathlib.Path) -> None: """A commit without agent provenance must still have the key, value empty string.""" repo = _make_repo(tmp_path) snap_id = _snap(repo) cid = _commit(repo, snap_id, message="human commit") _set_head(repo, "main", cid) r = _cg(repo) node = json.loads(r.output)["commits"][0] assert "agent_id" in node assert node["agent_id"] == "" def test_chain_preserves_provenance_per_node(self, tmp_path: pathlib.Path) -> None: """Each node in a multi-commit chain retains its own provenance.""" repo = _make_repo(tmp_path) snap_id = _snap(repo) c1 = _commit_with_provenance(repo, snap_id, agent_id="bot-a", model_id="m-a") c2 = _commit_with_provenance(repo, snap_id, parent=c1, agent_id="bot-b", model_id="m-b") _set_head(repo, "main", c2) r = _cg(repo) nodes = {n["commit_id"]: n for n in json.loads(r.output)["commits"]} assert nodes[c1]["agent_id"] == "bot-a" assert nodes[c1]["model_id"] == "m-a" assert nodes[c2]["agent_id"] == "bot-b" assert nodes[c2]["model_id"] == "m-b" class TestDataIntegrity: """Nodes returned by commit-graph must match CommitRecords on disk.""" def test_commit_id_matches_disk(self, tmp_path: pathlib.Path) -> None: from muse.core.commits import read_commit repo = _make_repo(tmp_path) snap_id = _snap(repo) cid = _commit(repo, snap_id) _set_head(repo, "main", cid) r = _cg(repo) node = json.loads(r.output)["commits"][0] record = read_commit(repo, node["commit_id"]) assert record is not None assert record.commit_id == node["commit_id"] def test_snapshot_id_matches_disk(self, tmp_path: pathlib.Path) -> None: from muse.core.commits import read_commit repo = _make_repo(tmp_path) snap_id = _snap(repo) cid = _commit(repo, snap_id) _set_head(repo, "main", cid) r = _cg(repo) node = json.loads(r.output)["commits"][0] record = read_commit(repo, node["commit_id"]) assert record is not None assert record.snapshot_id == node["snapshot_id"] def test_parent_chain_matches_disk(self, tmp_path: pathlib.Path) -> None: from muse.core.commits import read_commit repo = _make_repo(tmp_path) snap_id = _snap(repo) c1 = _commit(repo, snap_id, message="root") c2 = _commit(repo, snap_id, parent=c1, message="child") _set_head(repo, "main", c2) r = _cg(repo) nodes = {n["commit_id"]: n for n in json.loads(r.output)["commits"]} disk_c2 = read_commit(repo, c2) assert disk_c2 is not None assert nodes[c2]["parent_commit_id"] == disk_c2.parent_commit_id def test_count_matches_node_list_length(self, tmp_path: pathlib.Path) -> None: repo = _make_repo(tmp_path) snap_id = _snap(repo) c1 = _commit(repo, snap_id) c2 = _commit(repo, snap_id, parent=c1) c3 = _commit(repo, snap_id, parent=c2) _set_head(repo, "main", c3) r = _cg(repo) data = json.loads(r.output) assert data["count"] == len(data["commits"]) == 3 class TestPerformance: """Large graph walks must complete within acceptable time.""" def test_1000_commit_chain_under_5s(self, tmp_path: pathlib.Path) -> None: import time repo = _make_repo(tmp_path) snap_id = _snap(repo) parent: str | None = None for i in range(1000): parent = _commit(repo, snap_id, parent=parent, message=f"c{i}") _set_head(repo, "main", parent) # type: ignore[arg-type] start = time.monotonic() r = _cg(repo) elapsed = time.monotonic() - start assert r.exit_code == 0 data = json.loads(r.output) assert data["count"] == 1000 assert elapsed < 5.0, f"1000-commit walk took {elapsed:.2f}s" def test_duration_ms_plausible(self, tmp_path: pathlib.Path) -> None: import time repo = _make_repo(tmp_path) snap_id = _snap(repo) parent: str | None = None for i in range(20): parent = _commit(repo, snap_id, parent=parent, message=f"c{i}") _set_head(repo, "main", parent) # type: ignore[arg-type] start = time.monotonic() r = _cg(repo) wall = time.monotonic() - start data = json.loads(r.output) assert data["duration_ms"] <= (wall + 0.5) * 1000 # --------------------------------------------------------------------------- # Flag registration tests # --------------------------------------------------------------------------- import argparse as _argparse from muse.cli.commands.commit_graph import register as _register_commit_graph from muse.core.paths import head_path, ref_path def _parse_cg(*args: str) -> _argparse.Namespace: root_p = _argparse.ArgumentParser() subs = root_p.add_subparsers(dest="cmd") _register_commit_graph(subs) return root_p.parse_args(["commit-graph", *args]) class TestRegisterFlags: def test_default_json_out_is_false(self) -> None: ns = _parse_cg() assert ns.json_out is False def test_json_flag_sets_json_out(self) -> None: ns = _parse_cg("--json") assert ns.json_out is True def test_j_shorthand_sets_json_out(self) -> None: ns = _parse_cg("-j") assert ns.json_out is True def test_format_flag_no_longer_exists(self) -> None: import pytest with pytest.raises(SystemExit): _parse_cg("--format", "json")