davidalber/Geneagrapher — Issue #13: Use assertRaisesRegexp
Author: davidalber
Created: 2011-12-13 08:40:24+00:00
State: open
Labels: Task

A number of tests are written to verify an expected exception is raised and that its message matches what is expected. These tests are currently using `assertRaises` and a subsequent try-except block. Example:

self.assertRaises(DuplicateNodeError, self.graph1.add_node,
"Leonhard Euler", "Universitaet Basel",
1726, 38586, set(), set())

try:
self.graph1.add_node("Leonhard Euler", "Universitaet Basel",
1726, 38586, set(), set())
except DuplicateNodeError as e:
self.assertEqual(str(e),
"node with id {} already exists".format(38586))
else:
self.fail()

This can be improved by using [`assertRaisesRegexp`](http://docs.python.org/library/unittest.html#unittest.TestCase.assertRaisesRegexp).