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

@@ -554,6 +554,10 @@ class NetworkHostNotSet(NovaException):
message = _("Host is not set to the network (%(network_id)s).")
class NetworkBusy(NovaException):
message = _("Network %(network)s has active ports, cannot delete.")
class DatastoreNotFound(NotFound):
message = _("Could not find the datastore reference(s) which the VM uses.")