(a: dict, b: dict, what: str)
| 74 | |
| 75 | |
| 76 | def _assert_same(a: dict, b: dict, what: str) -> None: |
| 77 | keys_a = set(a) - {"__text__", "built_at_commit"} |
| 78 | keys_b = set(b) - {"__text__", "built_at_commit"} |
| 79 | assert keys_a == keys_b, f"{what} changed graph.json's top-level keys: {sorted(keys_a ^ keys_b)}" |
| 80 | nodes_a, edges_a = _canonical(a) |
| 81 | nodes_b, edges_b = _canonical(b) |
| 82 | only = { |
| 83 | "nodes only in the first": list((nodes_a - nodes_b).elements())[:5], |
| 84 | "nodes only in the second": list((nodes_b - nodes_a).elements())[:5], |
| 85 | "edges only in the first": list((edges_a - edges_b).elements())[:5], |
| 86 | "edges only in the second": list((edges_b - edges_a).elements())[:5], |
| 87 | } |
| 88 | assert not any(only.values()), f"{what} changed graph.json: " + json.dumps(only, indent=1)[:4000] |
| 89 | |
| 90 | |
| 91 | @pytest.fixture(scope="module", params=[False, True], ids=["no_cluster", "clustered"]) |
no test coverage detected