6 from optparse
import OptionParser
8 from git_stats
import testing
9 from git_stats
import config_tests
12 "config" : config_tests
16 """Dispatches test related commands
19 progname
= os
.path
.basename(sys
.argv
[0]) + " test"
20 parser
= OptionParser(prog
=progname
)
25 help="run tests for all known modules")
29 help="run the tests defined in the specified module")
34 help="run only the tests for the specified module")
40 help="run only the specified tests")
45 help="enable verbose output")
50 options
, args
= parser
.parse_args(list(args
))
55 # Add all modules we know about
57 tests
.extend(all_modules
.keys())
61 tests
.append(options
.single
)
63 # Also add all tests as specified as command arguments
69 module
= __import__("git_stats." + options
.module
, fromlist
=True)
70 except ImportError, e
:
71 parser
.error("Could not import module '%s'.\n%s" % (
72 options
.module
, str(e
)))
74 modules
.append(module
)
77 if not test
in all_modules
:
78 parser
.error("Unknown module '%s'." % test
)
80 module
= all_modules
[test
]
81 modules
.append(module
)
84 parser
.error("Please specify which modules to test")
88 for module
in modules
:
89 module_classes
= module
.getTestClasses()
90 classes
.extend(module_classes
)
92 runner
= testing
.GitTestRunner()
93 res
= runner
.runTests(options
, classes
)