diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2014-11-01 21:08:49 -0700 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2014-11-22 02:23:10 +0100 |
commit | 24035a6b3ed5ffdb1e75ebd375c3f7c2129742ff (patch) | |
tree | b7b7c636a58fde0cc89a2c1a9c4a82236ed49a1d /python/samba | |
parent | ed4c07b34b5571c021684e3df6bf5fc63cde69c5 (diff) | |
download | samba-24035a6b3ed5ffdb1e75ebd375c3f7c2129742ff.tar.gz samba-24035a6b3ed5ffdb1e75ebd375c3f7c2129742ff.tar.xz samba-24035a6b3ed5ffdb1e75ebd375c3f7c2129742ff.zip |
Move option parsing to samba.tests.subunitrun.
Change-Id: I2939c1b6ebb9739530efa9bc4667668cff7a7aeb
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'python/samba')
-rw-r--r-- | python/samba/tests/subunitrun.py | 27 |
1 files changed, 19 insertions, 8 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()) |