Mercurial > hg > periprocess
annotate tests/testall.py @ 1:a1b13d024582 default tip
remove non-existent entrypoints
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Wed, 30 Nov 2016 12:44:47 -0800 |
parents | d28351df9a8a |
children |
rev | line source |
---|---|
0
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
2 |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
3 """ |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
4 run all unit tests |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
5 """ |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
6 |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
7 import os |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
8 import sys |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
9 import unittest |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
10 |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
11 here = os.path.dirname(os.path.abspath(__file__)) |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
12 |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
13 def main(args=sys.argv[1:]): |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
14 |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
15 results = unittest.TestResult() |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
16 suite = unittest.TestLoader().discover(here, 'test_*.py') |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
17 suite.run(results) |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
18 n_errors = len(results.errors) |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
19 n_failures = len(results.failures) |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
20 print ("Run {} tests ({} failures; {} errors)".format(results.testsRun, |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
21 n_failures, |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
22 n_errors)) |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
23 if results.wasSuccessful(): |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
24 print ("Success") |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
25 sys.exit(0) |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
26 else: |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
27 # print failures and errors |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
28 for label, item in (('FAIL', results.failures), |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
29 ('ERROR', results.errors)): |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
30 if item: |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
31 print ("\n{}::\n".format(label)) |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
32 for index, (i, message) in enumerate(item): |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
33 print ('{}) {}:'.format(index, str(i))) |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
34 print (message) |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
35 sys.exit(1) |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
36 |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
37 if __name__ == '__main__': |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
38 main() |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
39 |
d28351df9a8a
initial commit from http://k0s.org/hg/config/file/tip/python/example/process.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
40 |