Skip to content

Commit

Permalink
Merge branch 'master' of github.com:LinuxCabal/Grafo-TDD
Browse files Browse the repository at this point in the history
Además, corregí lo de los tabuladores y espacios mixtos

Conflicts:
	Graph.py
	test_Graph.py
  • Loading branch information
renich committed Oct 19, 2012
2 parents 102d6a8 + 845bc7f commit fa628d1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
7 changes: 6 additions & 1 deletion Graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,17 @@ def add_edge(self, e):
self[v][w] = e
self[w][v] = e

def get_edge(self, v1, v2):
try:
return self[v1][v2]
except KeyError:
return None

def remove_edge( self, e ):
v1, v2 = e
self[v1].pop(v2)
self[v2].pop(v1)


def main(script, *args):
v = Vertex('v')
print v
Expand Down
12 changes: 10 additions & 2 deletions test_Graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ def setUp(self):
self.e2 = Edge(self.v, self.x)
self.g = Graph([self.v, self.w ,self.x, self.y],[self.e, self.e2])

def test_get_edge_not_exist(self):
edge = self.g.get_edge(self.v, self.y)
self.assertIsNone(edge)

def test_get_edge_exist(self):
edge = self.g.get_edge(self.v, self.w)
self.assertEqual(edge, self.e)

def test_remove_edge_is_removed( self ):
'''
La prueba checa si el Edge esta por ahi.
Expand All @@ -23,6 +31,6 @@ def test_remove_edge_is_removed( self ):
self.assertIsNone( self.g.get_edge( self.v, self.w ) )

if __name__ == '__main__':
suite = unittest.TestSuite()
unittest.TextTestRunner(verbosity = 2).run(suite)
unittest.main()


0 comments on commit fa628d1

Please sign in to comment.