From ba4b0291ef3a6ba914af1207460ce99c3cbe46bb Mon Sep 17 00:00:00 2001 From: Yu Yang Date: Wed, 27 Sep 2017 13:59:29 -0700 Subject: [PATCH] Follow comments, check exception message --- python/paddle/v2/framework/tests/test_exception.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/python/paddle/v2/framework/tests/test_exception.py b/python/paddle/v2/framework/tests/test_exception.py index 5284a069a..5ae048817 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__": -- GitLab