annotate makeitso/python_package/tests/testall.py @ 192:44bd0cc9bbc3

rename
author Jeff Hammel <k0scist@gmail.com>
date Thu, 08 May 2014 16:55:28 -0700
parents 3cccaa4d48cc
children 41d17337656a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
191
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
2
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
3 """
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
4 run all unit tests
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
5 """
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
6
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
7 import os
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
8 import sys
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
9 import unittest
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
10
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
11 here = os.path.dirname(os.path.abspath(__file__))
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
12
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
13 def main(args=sys.argv[1:]):
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
14
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
15 results = unittest.TestResult()
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
16 suite = unittest.TestLoader().discover(here, 'test_*.py')
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
17 suite.run(results)
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
18 n_errors = len(results.errors)
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
19 n_failures = len(results.failures)
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
20 print ("Run {} tests ({} failures; {} errors)".format(results.testsRun,
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
21 n_failures,
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
22 n_errors))
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
23 if results.wasSuccessful():
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
24 print ("Success")
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
25 sys.exit(0)
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
26 else:
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
27 if n_failures:
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
28 print (results.failures)
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
29 if n_errors:
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
30 print (results.errors)
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
31 results.printErrors()
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
32 sys.exit(1)
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
33
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
34 if __name__ == '__main__':
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
35 main()
3cccaa4d48cc add unittest runner
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
36