From d5c036d138d83160dfb9ad24c87d42f2d25dd7c3 Mon Sep 17 00:00:00 2001 From: Paul McGuire Date: Sun, 18 Aug 2019 22:45:54 -0500 Subject: Minor unit test cleanups --- unitTests.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/unitTests.py b/unitTests.py index 45465fb..34e925b 100644 --- a/unitTests.py +++ b/unitTests.py @@ -3855,10 +3855,15 @@ class ParseActionExceptionTest(ParseTestCase): try: expr.parseString('1 + 2') except Exception as e: - self.assertTrue(hasattr(e, '__cause__'), "no __cause__ attribute in the raised exception") - self.assertTrue(e.__cause__ is not None, "__cause__ not propagated to outer exception") - self.assertTrue(type(e.__cause__) == IndexError, "__cause__ references wrong exception") - traceback.print_exc() + print_traceback = True + try: + self.assertTrue(hasattr(e, '__cause__'), "no __cause__ attribute in the raised exception") + self.assertTrue(e.__cause__ is not None, "__cause__ not propagated to outer exception") + self.assertTrue(type(e.__cause__) == IndexError, "__cause__ references wrong exception") + print_traceback = False + finally: + if print_traceback: + traceback.print_exc() else: self.assertTrue(False, "Expected ParseException not raised") @@ -4801,7 +4806,8 @@ class MiscellaneousParserTests(ParseTestCase): # test creating Literal with empty string if "J" in runtests: print('verify non-fatal usage of Literal("")') - e = pp.Literal("") + with self.assertWarns(SyntaxWarning, msg="failed to warn use of empty string for Literal"): + e = pp.Literal("") try: e.parseString("SLJFD") except Exception as e: -- cgit v1.2.1