diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2010-03-31 04:19:36 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2010-03-31 04:19:36 +0200 |
commit | 6897be747594e385ee032ac1409289ce2d208548 (patch) | |
tree | f07c00e18c920b949988a8a2b6058146aad21378 /lib/testtools/testtools/run.py | |
parent | 5f3fcf7a7773737fd87c8ff5530fae2286e88927 (diff) | |
download | samba-6897be747594e385ee032ac1409289ce2d208548.tar.gz |
testtools: Fix included testtools, for systems that don't have it.
Diffstat (limited to 'lib/testtools/testtools/run.py')
-rwxr-xr-x | lib/testtools/testtools/run.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/testtools/testtools/run.py b/lib/testtools/testtools/run.py new file mode 100755 index 00000000000..c4f461ecfb8 --- /dev/null +++ b/lib/testtools/testtools/run.py @@ -0,0 +1,39 @@ +# Copyright (c) 2009 Jonathan M. Lange. See LICENSE for details. + +"""python -m testtools.run testspec [testspec...] + +Run some tests with the testtools extended API. + +For instance, to run the testtools test suite. + $ python -m testtools.run testtools.tests.test_suite +""" + +import sys + +from testtools.tests import test_suite +from testtools import TextTestResult + + +class TestToolsTestRunner(object): + """ A thunk object to support unittest.TestProgram.""" + + def run(self, test): + "Run the given test case or test suite." + result = TextTestResult(sys.stdout) + result.startTestRun() + try: + return test.run(result) + finally: + result.stopTestRun() + + +if __name__ == '__main__': + import optparse + from unittest import TestProgram + parser = optparse.OptionParser(__doc__) + args = parser.parse_args()[1] + if not args: + parser.error("No testspecs given.") + runner = TestToolsTestRunner() + program = TestProgram(module=None, argv=[sys.argv[0]] + args, + testRunner=runner) |