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' r = 'fake-reservation'
self.dbapi.reserve_node(r, uuid) self.dbapi.reserve_node(r, uuid)
try: exc = self.assertRaises(exception.NodeLocked, self.dbapi.reserve_node,
self.dbapi.reserve_node('another', uuid) 'another', uuid)
except exception.NodeLocked as e: self.assertIn(r, str(exc))
self.assertIn(r, str(e))
def test_reservation_non_existent_node(self): def test_reservation_non_existent_node(self):
node = utils.create_test_node() node = utils.create_test_node()