diff --git a/python/paddle/v2/framework/tests/test_exception.py b/python/paddle/v2/framework/tests/test_exception.py index 5284a069a8abae1e02288d63faca35228be74f8e..5ae048817cfcc1ec85e0d0e0c5db749da4521012 100644 --- a/python/paddle/v2/framework/tests/test_exception.py +++ b/python/paddle/v2/framework/tests/test_exception.py @@ -4,8 +4,13 @@ import unittest class TestException(unittest.TestCase): def test_exception(self): - self.assertRaises(core.EnforceNotMet, - lambda: core.__unittest_throw_exception__()) + ex = None + try: + core.__unittest_throw_exception__() + except core.EnforceNotMet as ex: + self.assertIn("test exception", ex.message) + + self.assertIsNotNone(ex) if __name__ == "__main__":