def test_directed_edge_has_attr(self): """ Check if a directed edge has a particular attribute """ v0 = DirectedVertex(val='v0') v1 = DirectedVertex(val='v1') e01 = DirectedEdge((v0, v1), attrs={'weight': 5, 0: 1}) self.assertTrue(e01.has_attr('weight')) self.assertFalse(e01.has_attr('length')) e01.del_attr('weight') self.assertFalse(e01.has_attr('weight'))
def test_directed_edge_del_attr(self): """ Delete an attribute of a directed edge """ v0 = DirectedVertex(val='v0') v1 = DirectedVertex(val='v1') e01 = DirectedEdge((v0, v1), attrs={'weight': 5, 0: 1}) e01.del_attr('weight') self.assertEqual(e01.attrs, {0: 1}) e01.del_attr(0) self.assertEqual(e01.attrs, {})