(tmp_path)
| 11 | |
| 12 | |
| 13 | def _write_cycle_graph(tmp_path): |
| 14 | g = nx.DiGraph() |
| 15 | g.add_node("a", label="a.py", file_type="code", source_file="a.py") |
| 16 | g.add_node("b", label="b.py", file_type="code", source_file="b.py") |
| 17 | g.add_node("c", label="c.py", file_type="code", source_file="c.py") |
| 18 | g.add_node("d", label="d.py", file_type="code", source_file="d.py") |
| 19 | # 2-file cycle: a.py <-> b.py |
| 20 | g.add_edge("a", "b", relation="imports_from", source_file="a.py", confidence="EXTRACTED") |
| 21 | g.add_edge("b", "a", relation="imports_from", source_file="b.py", confidence="EXTRACTED") |
| 22 | # 3-file cycle: b.py -> c.py -> d.py -> b.py |
| 23 | g.add_edge("b", "c", relation="imports_from", source_file="b.py", confidence="EXTRACTED") |
| 24 | g.add_edge("c", "d", relation="imports_from", source_file="c.py", confidence="EXTRACTED") |
| 25 | g.add_edge("d", "b", relation="imports_from", source_file="d.py", confidence="EXTRACTED") |
| 26 | gp = tmp_path / "graph.json" |
| 27 | gp.write_text(json.dumps(json_graph.node_link_data(g, edges="links")), encoding="utf-8") |
| 28 | return gp |
| 29 | |
| 30 | |
| 31 | def _write_acyclic_graph(tmp_path): |
no test coverage detected