def test_dependencies_graph(dest): imports._dependencies_graph(dest, {'labas': ['hoho', 'yep'], 'hoho': ['yep']}) with open(dest) as stream: assert stream.read().strip() == ''' digraph "dependencies_graph" { rankdir=LR charset="utf-8" URL="." node[shape="box"] "hoho" []; "yep" []; "labas" []; "yep" -> "hoho" []; "hoho" -> "labas" []; "yep" -> "labas" []; } '''.strip()
def test_dependencies_graph(dest): imports._dependencies_graph(dest, {"labas": ["hoho", "yep"], "hoho": ["yep"]}) with open(dest) as stream: assert ( stream.read().strip() == """ digraph "dependencies_graph" { rankdir=LR charset="utf-8" URL="." node[shape="box"] "hoho" []; "yep" []; "labas" []; "yep" -> "hoho" []; "hoho" -> "labas" []; "yep" -> "labas" []; } """.strip() )
def test_dependencies_graph(dest: str) -> None: """DOC files are correctly generated, and the graphname is the basename.""" imports._dependencies_graph(dest, { "labas": {"hoho", "yep"}, "hoho": {"yep"} }) with open(dest, encoding="utf-8") as stream: assert (stream.read().strip() == """ digraph "foo" { rankdir=LR charset="utf-8" URL="." node[shape="box"] "hoho" []; "yep" []; "labas" []; "yep" -> "hoho" []; "hoho" -> "labas" []; "yep" -> "labas" []; } """.strip())
def test_missing_graphviz(filename: str) -> None: """Raises if graphviz is not installed, and defaults to png if no extension given.""" with pytest.raises(RuntimeError, match=r"Cannot generate `graph\.png`.*"): imports._dependencies_graph(filename, {"a": {"b", "c"}, "b": {"c"}})