Fail test if excepted error was not raised

test_reservation_in_exception_message is expecting
NodeLocked error. If it does happen, the test should
be fine. But if it does not, we should fail the test.

Change-Id: I02145db698983387ecb6951a732641fa5bbb9f13
This commit is contained in:
Tang Chen 2016-09-29 18:36:39 +08:00
parent 0a9abccd8c
commit 9d8609017a
1 changed files with 3 additions and 4 deletions

View File

@ -523,10 +523,9 @@ class DbNodeTestCase(base.DbTestCase):
r = 'fake-reservation'
self.dbapi.reserve_node(r, uuid)
try:
self.dbapi.reserve_node('another', uuid)
except exception.NodeLocked as e:
self.assertIn(r, str(e))
exc = self.assertRaises(exception.NodeLocked, self.dbapi.reserve_node,
'another', uuid)
self.assertIn(r, str(exc))
def test_reservation_non_existent_node(self):
node = utils.create_test_node()