def test_subgraphs(self): g = pydot.Graph() s = pydot.Subgraph("foo") self.assertEqual(g.get_subgraphs(), []) self.assertEqual(g.get_subgraph_list(), []) g.add_subgraph(s) self.assertEqual(g.get_subgraphs()[0].get_name(), s.get_name()) self.assertEqual(g.get_subgraph_list()[0].get_name(), s.get_name())
def test_graph_pickling(self): import pickle g = pydot.Graph() s = pydot.Subgraph("foo") g.add_subgraph(s) g.add_edge(pydot.Edge('A', 'B')) g.add_edge(pydot.Edge('A', 'C')) g.add_edge(pydot.Edge(('D', 'E'))) g.add_node(pydot.Node('node!')) self.assertEqual(type(pickle.dumps(g)), bytes)
def test_graph_is_picklabe(): import pickle graph = pydot.Graph() subgraph = pydot.Subgraph("foo") graph.add_subgraph(subgraph) graph.add_edge(pydot.Edge("A", "B")) graph.add_edge(pydot.Edge("A", "C")) graph.add_edge(pydot.Edge(("D", "E"))) graph.add_node(pydot.Node("node!")) assert isinstance(pickle.dumps(graph), bytes)
def test_subgraphs(): graph = pydot.Graph() subgraph = pydot.Subgraph("foo") assert graph.get_subgraphs() == [] assert graph.get_subgraph_list() == [] graph.add_subgraph(subgraph) assert len(graph.get_subgraphs()) == 1 assert len(graph.get_subgraph_list()) == 1 assert graph.get_subgraphs()[0].get_name() == subgraph.get_name() assert graph.get_subgraph_list()[0].get_name() == subgraph.get_name()
def _reset_graphs(self): self.graph_directed = pydot.Graph('testgraph', graph_type='digraph')
def digraph(): return pydot.Graph("testgraph", graph_type="digraph")