[geneagrapher] 171/226: Expanded test of DuplicateNodeError, fixed bug with its message.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Sat Jul 11 17:11:03 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch master
in repository geneagrapher.

commit a6e892410b5f0ae4d17e097b4e9fa1d3376968db
Author: David Alber <alber.david at gmail.com>
Date:   Sun Nov 6 23:15:36 2011 -0800

    Expanded test of DuplicateNodeError, fixed bug with its message.
---
 geneagrapher/graph/graph.py | 5 +++--
 tests/test_graph_methods.py | 7 +++++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/geneagrapher/graph/graph.py b/geneagrapher/graph/graph.py
index d6b6704..ed58c3b 100644
--- a/geneagrapher/graph/graph.py
+++ b/geneagrapher/graph/graph.py
@@ -4,8 +4,9 @@ from record import Record
 class DuplicateNodeError(Exception):
     def __init__(self, value):
         self.value = value
-        def __str__(self):
-            return repr(self.value)
+
+    def __str__(self):
+        return self.value
 
 class Graph:
     """
diff --git a/tests/test_graph_methods.py b/tests/test_graph_methods.py
index 907cf91..b9d348e 100644
--- a/tests/test_graph_methods.py
+++ b/tests/test_graph_methods.py
@@ -76,6 +76,13 @@ class TestGraphMethods(unittest.TestCase):
         self.assertEquals([38586, 18231], self.graph1.get_node_list())
         self.assertRaises(DuplicateNodeError, self.graph1.add_node, "Leonhard Euler", "Universitaet Basel", 1726, 38586, [], [])
 
+        try:
+            self.graph1.add_node("Leonhard Euler", "Universitaet Basel", 1726, 38586, [], [])
+        except DuplicateNodeError as e:
+            self.assertEquals(str(e), "node with id {} already exists".format(38586))
+        else:
+            self.fail()
+
     def test013_add_node_object(self):
         # Test the add_node_object() method.
         record = Record("Leonhard Euler", "Universitaet Basel", 1726, 38586)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/geneagrapher.git



More information about the debian-science-commits mailing list