diff options
author | Paul McGuire <ptmcg@austin.rr.com> | 2019-04-07 07:42:20 -0500 |
---|---|---|
committer | Paul McGuire <ptmcg@austin.rr.com> | 2019-04-07 07:42:20 -0500 |
commit | 76b3af7f25d0f25d4eb7f0849a23e22b5b2a0297 (patch) | |
tree | 53ae14557c3bbbe7545983ee7414f442f2fe4d07 /simple_unit_tests.py | |
parent | a2439508ba5c94546db98593cfa676de9b59babe (diff) | |
download | pyparsing-git-76b3af7f25d0f25d4eb7f0849a23e22b5b2a0297.tar.gz |
Improved support for "python setup.py test"
Diffstat (limited to 'simple_unit_tests.py')
-rw-r--r-- | simple_unit_tests.py | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/simple_unit_tests.py b/simple_unit_tests.py index a40795b..7e42003 100644 --- a/simple_unit_tests.py +++ b/simple_unit_tests.py @@ -94,7 +94,7 @@ class PyparsingExpressionTestCase(unittest.TestCase): self.assertTrue(False, "failed to raise expected exception") -#=========== TEST DEFINITIONS START HERE ============== +# =========== TEST DEFINITIONS START HERE ============== class TestLiteral(PyparsingExpressionTestCase): tests = [ @@ -444,20 +444,26 @@ class TestCommonHelperExpressions(PyparsingExpressionTestCase): ] -#============ MAIN ================ - -if __name__ == '__main__': +def _get_decl_line_no(cls): import inspect - def get_decl_line_no(cls): - return inspect.getsourcelines(cls)[1] + return inspect.getsourcelines(cls)[1] + - # get all test case classes defined in this module and sort them by decl line no - test_case_classes = list(PyparsingExpressionTestCase.__subclasses__()) - test_case_classes.sort(key=get_decl_line_no) +# get all test case classes defined in this module and sort them by decl line no +test_case_classes = list(PyparsingExpressionTestCase.__subclasses__()) +test_case_classes.sort(key=_get_decl_line_no) - # make into a suite and run it - this will run the tests in the same order - # they are declared in this module - suite = unittest.TestSuite(cls() for cls in test_case_classes) +# make into a suite and run it - this will run the tests in the same order +# they are declared in this module +# +# runnable from setup.py using "python setup.py test -s simple_unit_tests.suite" +# +suite = unittest.TestSuite(cls() for cls in test_case_classes) + + +# ============ MAIN ================ + +if __name__ == '__main__': result = unittest.TextTestRunner().run(suite) exit(0 if result.wasSuccessful() else 1) |