(tmp_path, source, service="Svc")
| 5 | |
| 6 | |
| 7 | def _extract(tmp_path, source, service="Svc"): |
| 8 | package = tmp_path / "pkg" |
| 9 | package.mkdir(exist_ok=True) |
| 10 | (package / "__init__.py").write_text("", encoding="utf-8") |
| 11 | (package / "service.py").write_text( |
| 12 | f"class {service}:\n def create(self): return 1\n", encoding="utf-8" |
| 13 | ) |
| 14 | (package / "caller.py").write_text(source, encoding="utf-8") |
| 15 | result = extract(sorted(package.glob("*.py")), root=tmp_path, |
| 16 | cache_root=tmp_path / "graphify-out", parallel=False) |
| 17 | nodes = {node["id"]: node for node in result["nodes"]} |
| 18 | return [edge for edge in result["edges"] |
| 19 | if edge["relation"] == "calls" |
| 20 | and nodes[edge["source"]]["label"] == "run()" |
| 21 | and nodes[edge["target"]]["label"] == ".create()"] |
| 22 | |
| 23 | |
| 24 | @pytest.mark.parametrize("service,instance", [("Svc", "g"), ("lower_svc", "lower_svc"), |
no test coverage detected