diff options
-rw-r--r-- | simple_unit_tests.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/simple_unit_tests.py b/simple_unit_tests.py index 875ded7..f13ff07 100644 --- a/simple_unit_tests.py +++ b/simple_unit_tests.py @@ -29,6 +29,7 @@ class PyparsingExpressionTestCase(unittest.TestCase): given text strings. Subclasses must define a class attribute 'tests' which is a list of PpTestSpec instances. """ + tests = [] def runTest(self): if self.__class__ is PyparsingExpressionTestCase: return @@ -71,12 +72,13 @@ class PyparsingExpressionTestCase(unittest.TestCase): else: # expect fail - with self.assertRaises(pp.ParseException) as ar: + try: parsefn(test_spec.text) - print(' ', test_spec.text or "''") - print(' ', ' '*ar.exception.loc+'^') - print(' ', ar.exception.msg) - self.assertEqual(ar.exception.loc, test_spec.expected_fail_locn) + except Exception as exc: + print(pp.ParseException.explain(exc)) + self.assertEqual(exc.loc, test_spec.expected_fail_locn) + else: + self.assertTrue(False, "failed to raise expected exception") #=========== TEST DEFINITIONS START HERE ============== |