def test_invalid_edge(self): dag = Dag(1, 2) with self.assertRaises(KeyError): dag.add_edge(1, 3) with self.assertRaises(KeyError): dag.add_edge(5, 2) dag.add_edge(1, 2)
def test_edge(self): dag = Dag(1, 2) edge = dag.add_edge(1, 2) self.assertIs(edge, dag.edge(1, 2))
def test_two_edges(self): dag = Dag(1, 2, 3) edge0 = dag.add_edge(1, 2) edge1 = dag.add_edge(2, 3) self.assertEqual({edge0, edge1}, dag.edges())
def test_add_same_edges(self): dag = Dag(1, 2) edge = dag.add_edge(1, 2) self.assertIs(edge, dag.add_edge(1, 2))
def test_add_edge(self): dag = Dag(9, 2) edge = dag.add_edge(9, 2) self.assertIs(dag[9], edge.src) self.assertIs(dag[2], edge.dst) self.assertEqual({edge}, dag.edges())