summaryrefslogtreecommitdiff
path: root/simple_unit_tests.py
diff options
context:
space:
mode:
authorPaul McGuire <ptmcg@austin.rr.com>2018-09-23 23:47:20 -0500
committerPaul McGuire <ptmcg@austin.rr.com>2018-09-23 23:47:20 -0500
commit389a8d74b0e9ceef97c782693faa2f294a0f1c9d (patch)
tree821411b9f59fef1853a57e6c5f696c407fc18b8e /simple_unit_tests.py
parent16265a44d1cbd2924044eebffd9345b602a19ae3 (diff)
downloadpyparsing-git-389a8d74b0e9ceef97c782693faa2f294a0f1c9d.tar.gz
force order of simple unit tests to make it easier to see test output corresponding to each test case
Diffstat (limited to 'simple_unit_tests.py')
-rw-r--r--simple_unit_tests.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/simple_unit_tests.py b/simple_unit_tests.py
index 5266c92..7b8bf2c 100644
--- a/simple_unit_tests.py
+++ b/simple_unit_tests.py
@@ -25,7 +25,7 @@ class PyparsingExpressionTestCase(unittest.TestCase):
given text strings. Subclasses must define a class attribute 'tests' which
is a list of PpTestSpec instances.
"""
- def test_match(self):
+ def runTest(self):
if self.__class__ is PyparsingExpressionTestCase:
return
@@ -326,4 +326,15 @@ if __name__ == '__main__':
print("simple_unit_tests.py runs on Python 3 only")
sys.exit(0)
- unittest.main() \ No newline at end of file
+ import inspect
+ def get_decl_line_no(cls):
+ 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)
+
+ # 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)
+ unittest.TextTestRunner().run(suite)