3 # Simple subunit testrunner for python
5 # NOTE: DO NOT USE THIS MODULE FOR NEW CODE.
7 # Instead, use the standard subunit runner - e.g. "python -m subunit.run
10 # This wrapper will be removed once all tests can be run
11 # without it. At the moment there are various tests which still
12 # get e.g. credentials passed via command-line options to this
15 # Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007-2014
17 # This program is free software; you can redistribute it and/or modify
18 # it under the terms of the GNU General Public License as published by
19 # the Free Software Foundation; either version 3 of the License, or
20 # (at your option) any later version.
22 # This program is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU General Public License for more details.
27 # You should have received a copy of the GNU General Public License
28 # along with this program. If not, see <http://www.gnu.org/licenses/>.
31 # make sure the script dies immediately when hitting control-C,
32 # rather than raising KeyboardInterrupt. As we do all database
33 # operations using transactions, this is safe.
35 signal
.signal(signal
.SIGINT
, signal
.SIG_DFL
)
40 from samba
.subunit
.run
import TestProgram
as BaseTestProgram
43 class SubunitOptions(optparse
.OptionGroup
):
44 """Command line options for subunit test runners."""
46 def __init__(self
, parser
):
47 optparse
.OptionGroup
.__init
__(self
, parser
, "Subunit Options")
48 self
.add_option('-l', '--list', dest
='listtests', default
=False,
49 help='List tests rather than running them.',
51 self
.add_option('--load-list', dest
='load_list', default
=None,
52 help='Specify a filename containing the test ids to use.')
55 class TestProgram(BaseTestProgram
):
57 def __init__(self
, module
=None, args
=None, opts
=None):
60 if getattr(opts
, "listtests", False):
61 args
.insert(0, "--list")
62 if getattr(opts
, 'load_list', None):
63 args
.insert(0, "--load-list=%s" % opts
.load_list
)
64 argv
= [sys
.argv
[0]] + args
65 super(TestProgram
, self
).__init
__(module
=module
, argv
=argv
)