diff options
author | ptmcg <ptmcg@austin.rr.com> | 2018-10-31 00:50:00 -0500 |
---|---|---|
committer | ptmcg <ptmcg@austin.rr.com> | 2018-10-31 00:50:00 -0500 |
commit | e5a443638133be0f9eef26a5f0a6fdc8557a5ce4 (patch) | |
tree | 4682df4008ae0d646319f911302ecf4740fb08e3 /unitTests.py | |
parent | fbafa927cbc5defdd060adeb08ba4082bbc1d71f (diff) | |
download | pyparsing-git-e5a443638133be0f9eef26a5f0a6fdc8557a5ce4.tar.gz |
assertRaises not compatible in Py2.6pyparsing_2.3.0
Diffstat (limited to 'unitTests.py')
-rw-r--r-- | unitTests.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/unitTests.py b/unitTests.py index 31832b7..e54d68b 100644 --- a/unitTests.py +++ b/unitTests.py @@ -3526,15 +3526,16 @@ class ParseActionExceptionTest(ParseTestCase): number.setParseAction(number_action)
symbol = pp.Word('abcd', max=1)
expr = number | symbol
- with self.assertRaises(pp.ParseException):
- try:
- expr.parseString('1 + 2')
- except Exception as e:
- assert hasattr(e, '__cause__'), "no __cause__ attribute in the raised exception"
- assert e.__cause__ is not None, "__cause__ not propagated to outer exception"
- assert type(e.__cause__) == IndexError, "__cause__ references wrong exception"
- traceback.print_exc()
- raise
+
+ 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()
+ else:
+ self.assertTrue(False, "Expected ParseException not raised")
class ParseActionNestingTest(ParseTestCase):
# tests Issue #22
|