Mercurial > hg > MakeItSo
annotate makeitso/python_package/tests/testall.py @ 248:407dd46857e1
fix syntax error in python.py + version bump
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Fri, 31 Mar 2017 18:05:28 -0700 |
parents | 41d17337656a |
children |
rev | line source |
---|---|
191 | 1 #!/usr/bin/env python |
2 | |
3 """ | |
4 run all unit tests | |
5 """ | |
6 | |
7 import os | |
8 import sys | |
9 import unittest | |
10 | |
11 here = os.path.dirname(os.path.abspath(__file__)) | |
12 | |
13 def main(args=sys.argv[1:]): | |
14 | |
15 results = unittest.TestResult() | |
16 suite = unittest.TestLoader().discover(here, 'test_*.py') | |
17 suite.run(results) | |
18 n_errors = len(results.errors) | |
19 n_failures = len(results.failures) | |
20 print ("Run {} tests ({} failures; {} errors)".format(results.testsRun, | |
21 n_failures, | |
22 n_errors)) | |
23 if results.wasSuccessful(): | |
24 print ("Success") | |
25 sys.exit(0) | |
26 else: | |
194
41d17337656a
STUB: makeitso/python_package/tests/testall.py
Jeff Hammel <k0scist@gmail.com>
parents:
191
diff
changeset
|
27 # print failures and errors |
41d17337656a
STUB: makeitso/python_package/tests/testall.py
Jeff Hammel <k0scist@gmail.com>
parents:
191
diff
changeset
|
28 for label, item in (('FAIL', results.failures), |
41d17337656a
STUB: makeitso/python_package/tests/testall.py
Jeff Hammel <k0scist@gmail.com>
parents:
191
diff
changeset
|
29 ('ERROR', results.errors)): |
41d17337656a
STUB: makeitso/python_package/tests/testall.py
Jeff Hammel <k0scist@gmail.com>
parents:
191
diff
changeset
|
30 if item: |
41d17337656a
STUB: makeitso/python_package/tests/testall.py
Jeff Hammel <k0scist@gmail.com>
parents:
191
diff
changeset
|
31 print ("\n{}::\n".format(label)) |
41d17337656a
STUB: makeitso/python_package/tests/testall.py
Jeff Hammel <k0scist@gmail.com>
parents:
191
diff
changeset
|
32 for index, (i, message) in enumerate(item): |
41d17337656a
STUB: makeitso/python_package/tests/testall.py
Jeff Hammel <k0scist@gmail.com>
parents:
191
diff
changeset
|
33 print ('{}) {}:'.format(index, str(i))) |
41d17337656a
STUB: makeitso/python_package/tests/testall.py
Jeff Hammel <k0scist@gmail.com>
parents:
191
diff
changeset
|
34 print (message) |
191 | 35 sys.exit(1) |
36 | |
37 if __name__ == '__main__': | |
38 main() | |
39 |