diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2010-01-08 02:09:20 +0100 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2010-01-16 19:53:49 +1300 |
commit | 28577aae928847e64a0274b5922e26e1f15d9916 (patch) | |
tree | 78f6b36e8166d3320120df0e1bc91fef7ce8f9b1 /lib/subunit/python/testtools/run.py | |
parent | b6b46b4978dcaffa0cd9803c43b8a5f1c19e227e (diff) | |
download | samba-28577aae928847e64a0274b5922e26e1f15d9916.tar.gz samba-28577aae928847e64a0274b5922e26e1f15d9916.tar.bz2 samba-28577aae928847e64a0274b5922e26e1f15d9916.zip |
Import testtools as well, required for subunit.
Diffstat (limited to 'lib/subunit/python/testtools/run.py')
-rwxr-xr-x | lib/subunit/python/testtools/run.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/subunit/python/testtools/run.py b/lib/subunit/python/testtools/run.py new file mode 100755 index 0000000000..c4f461ecfb --- /dev/null +++ b/lib/subunit/python/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) |