diff options
-rw-r--r-- | python/samba/tests/subunitrun.py | 27 | ||||
-rwxr-xr-x | source4/dsdb/tests/python/dirsync.py | 2 | ||||
-rwxr-xr-x | source4/scripting/bin/subunitrun | 4 |
3 files changed, 23 insertions, 10 deletions
diff --git a/python/samba/tests/subunitrun.py b/python/samba/tests/subunitrun.py index 78632f364a..abb98813db 100644 --- a/python/samba/tests/subunitrun.py +++ b/python/samba/tests/subunitrun.py @@ -28,18 +28,15 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # -import sys - # make sure the script dies immediately when hitting control-C, # rather than raising KeyboardInterrupt. As we do all database # operations using transactions, this is safe. import signal signal.signal(signal.SIGINT, signal.SIG_DFL) -# Find right directory when running from source tree -sys.path.insert(0, "bin/python") - +import optparse import samba +import sys samba.ensure_external_module("mimeparse", "mimeparse") samba.ensure_external_module("extras", "extras") samba.ensure_external_module("testtools", "testtools") @@ -47,13 +44,27 @@ samba.ensure_external_module("subunit", "subunit/python") import subunit.run try: - from subunit.run import TestProgram + from subunit.run import TestProgram as BaseTestProgram except ImportError: - from unittest import TestProgram + from unittest import TestProgram as BaseTestProgram + + +class SubunitOptions(optparse.OptionGroup): + """Command line options for subunit test runners.""" + + def __init__(self, parser): + optparse.OptionGroup.__init__(self, parser, "Subunit Options") + self.add_option('-l', '--list', dest='listtests', default=False, + help='List tests rather than running them.', + action="store_true") + self.add_option('--load-list', dest='load_list', default=None, + help='Specify a filename containing the test ids to use.') -class TestProgram(TestProgram): +class TestProgram(BaseTestProgram): def __init__(self, module=None, argv=None): + if argv is None: + argv = [sys.argv[0]] super(TestProgram, self).__init__(module=module, argv=argv, testRunner=subunit.run.SubunitTestRunner()) diff --git a/source4/dsdb/tests/python/dirsync.py b/source4/dsdb/tests/python/dirsync.py index 2de77366ec..a480518790 100755 --- a/source4/dsdb/tests/python/dirsync.py +++ b/source4/dsdb/tests/python/dirsync.py @@ -702,4 +702,4 @@ if getattr(opts, 'load_list', None): args.insert(0, "--load-list=%s" % opts.load_list) -TestProgram(module=__name__, argv=[sys.argv[0]] + args) +TestProgram(module=__name__) diff --git a/source4/scripting/bin/subunitrun b/source4/scripting/bin/subunitrun index c85fc97fb2..48b507a7b4 100755 --- a/source4/scripting/bin/subunitrun +++ b/source4/scripting/bin/subunitrun @@ -39,7 +39,7 @@ sys.path.insert(0, "bin/python") import optparse import samba -from samba.tests.subunitrun import TestProgram +from samba.tests.subunitrun import TestProgram, SubunitOptions import samba.getopt as options import samba.tests @@ -71,8 +71,10 @@ parser = optparse.OptionParser(usage=usage, description=description) parser.format_description = format_description credopts = options.CredentialsOptions(parser) sambaopts = options.SambaOptions(parser) +subunitopts = SubunitOptions(parser) parser.add_option_group(credopts) parser.add_option_group(sambaopts) +parser.add_option_group(subunitopts) opts, args = parser.parse_args() |