Mercurial > mozilla > hg > licenser
comparison tests/test.py @ 24:d3e3a506dd29
tests now pass
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Thu, 24 Nov 2011 15:29:05 -0800 |
parents | cf920f85fb98 |
children |
comparison
equal
deleted
inserted
replaced
23:ba47f936e9f6 | 24:d3e3a506dd29 |
---|---|
9 import shutil | 9 import shutil |
10 import sys | 10 import sys |
11 import tempfile | 11 import tempfile |
12 from optparse import OptionParser | 12 from optparse import OptionParser |
13 | 13 |
14 def run_tests(raise_on_error=False, report_first=False): | 14 def run_tests(raise_on_error=False, report_first=False, cleanup=True): |
15 | 15 |
16 # add results here | 16 # add results here |
17 results = {} | 17 results = {} |
18 | 18 |
19 # doctest arguments | 19 # doctest arguments |
41 raise | 41 raise |
42 except doctest.UnexpectedException, failure: | 42 except doctest.UnexpectedException, failure: |
43 raise failure.exc_info[0], failure.exc_info[1], failure.exc_info[2] | 43 raise failure.exc_info[0], failure.exc_info[1], failure.exc_info[2] |
44 finally: | 44 finally: |
45 # cleanup | 45 # cleanup |
46 shutil.rmtree(tempdir) | 46 if cleanup: |
47 shutil.rmtree(tempdir) | |
48 else: | |
49 print '%s: %s' % (test, tempdir) | |
47 | 50 |
48 return results | 51 return results |
49 | 52 |
50 def main(args=sys.argv[1:]): | 53 def main(args=sys.argv[1:]): |
51 | 54 |
55 default=False, action='store_true', | 58 default=False, action='store_true', |
56 help="raise on first error") | 59 help="raise on first error") |
57 parser.add_option('--report-first', dest='report_first', | 60 parser.add_option('--report-first', dest='report_first', |
58 default=False, action='store_true', | 61 default=False, action='store_true', |
59 help="report the first error only (all tests will still run)") | 62 help="report the first error only (all tests will still run)") |
63 parser.add_option('--no-cleanup', dest='cleanup', | |
64 action='store_false', default=True, | |
65 help="don't cleanup following the tests") | |
60 options, args = parser.parse_args(args) | 66 options, args = parser.parse_args(args) |
61 | 67 |
62 # run the tests | 68 # run the tests |
63 results = run_tests(**options.__dict__) | 69 results = run_tests(**options.__dict__) |
64 if sum([i.failed for i in results.values()]): | 70 if sum([i.failed for i in results.values()]): |