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