summaryrefslogtreecommitdiff
path: root/source4/scripting/bin
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2010-12-10 03:03:18 +0100
committerJelmer Vernooij <jelmer@samba.org>2010-12-10 03:49:03 +0100
commit10441ed83d701d6db64c3a933cf09957355e1db2 (patch)
treedbe01ab4dc39e5da4769e0578cb00158154522ee /source4/scripting/bin
parent636d8cfb423bbdf271df25efbc13c91420ebefe8 (diff)
downloadsamba-10441ed83d701d6db64c3a933cf09957355e1db2.tar.gz
samba-10441ed83d701d6db64c3a933cf09957355e1db2.tar.bz2
samba-10441ed83d701d6db64c3a933cf09957355e1db2.zip
subunitrun: Use unittest.TestProgram if subunit.TestProgram is not
available. Autobuild-User: Jelmer Vernooij <jelmer@samba.org> Autobuild-Date: Fri Dec 10 03:49:03 CET 2010 on sn-devel-104
Diffstat (limited to 'source4/scripting/bin')
-rwxr-xr-xsource4/scripting/bin/subunitrun22
1 files changed, 11 insertions, 11 deletions
diff --git a/source4/scripting/bin/subunitrun b/source4/scripting/bin/subunitrun
index 21243a73ec..bc7b42c610 100755
--- a/source4/scripting/bin/subunitrun
+++ b/source4/scripting/bin/subunitrun
@@ -26,12 +26,7 @@ import optparse
import samba
samba.ensure_external_module("testtools", "testtools")
samba.ensure_external_module("subunit", "subunit/python")
-try:
- from subunit.run import SubunitTestRunner, TestProgram
-except ImportError:
- samba.force_bundled_package("testtools", "testtools")
- samba.force_bundled_package("subunit", "subunit/python")
- from subunit.run import SubunitTestRunner, TestProgram
+from subunit.run import SubunitTestRunner
import samba.getopt as options
import samba.tests
@@ -39,15 +34,20 @@ import samba.tests
parser = optparse.OptionParser("subunitrun [options] <tests>")
credopts = options.CredentialsOptions(parser)
parser.add_option_group(credopts)
-parser.add_option('-l', '--list', dest='listtests', default=False,
- help='List tests rather than running them.',
- action="store_true")
+try:
+ from subunit.run import TestProgram
+except ImportError:
+ from unittest import TestProgram
+else:
+ parser.add_option('-l', '--list', dest='listtests', default=False,
+ help='List tests rather than running them.',
+ action="store_true")
opts, args = parser.parse_args()
samba.tests.cmdline_credentials = credopts.get_credentials(samba.tests.env_loadparm())
-if opts.listtests:
+if getattr(opts, "listtests", False):
args.insert(0, "--list")
runner = SubunitTestRunner()
-program = TestProgram(module=None, argv=[sys.argv[0]] + args, testRunner=runner, stdout=sys.stdout)
+program = TestProgram(module=None, argv=[sys.argv[0]] + args, testRunner=runner)