From 9d8609017ac4fd3dfe1a27d8861e7255663ec823 Mon Sep 17 00:00:00 2001 From: Tang Chen Date: Thu, 29 Sep 2016 18:36:39 +0800 Subject: [PATCH] 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 --- ironic/tests/unit/db/test_nodes.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ironic/tests/unit/db/test_nodes.py b/ironic/tests/unit/db/test_nodes.py index 9e5f7fbc9b..43ca24480f 100644 --- a/ironic/tests/unit/db/test_nodes.py +++ b/ironic/tests/unit/db/test_nodes.py @@ -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()