summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul McGuire <ptmcg@austin.rr.com>2019-08-18 22:45:54 -0500
committerPaul McGuire <ptmcg@austin.rr.com>2019-08-18 22:45:54 -0500
commitd5c036d138d83160dfb9ad24c87d42f2d25dd7c3 (patch)
tree757ddcdfa3828e9810802ee9413b94c88bb2c506
parent92e79f0f4217d031ef1b8c45127baa3efdeaa420 (diff)
downloadpyparsing-git-d5c036d138d83160dfb9ad24c87d42f2d25dd7c3.tar.gz
Minor unit test cleanups
-rw-r--r--unitTests.py16
1 files 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: