assertRaises(Exception, ...) considered harmful

Expecting that Exception is raised can end up passing an a test when an
unexpected error occurs. For instance, errors in the unit test itself
can be masked:

https://review.openstack.org/4848
https://review.openstack.org/4873
https://review.openstack.org/4874

Change a variety of unit tests to expect a more specific exception so
we don't run into false positive tests in the future.

Change-Id: Ibc0c63b1f6b5574a3ce93d9f02c9d1ff5ac4a8b0
This commit is contained in:
Johannes Erdfelt
2012-03-03 17:53:41 +00:00
parent 60105a66d5
commit c4802fa465
9 changed files with 78 additions and 53 deletions

View File

@@ -115,6 +115,10 @@ def skip_if_fake(func):
return _skipper
class TestingException(Exception):
pass
class TestCase(unittest.TestCase):
"""Test case base class for all unit tests."""