libsmb: Use clistr_smb2_extract_snapshot_token() in cli_smb2_create_fnum_send()
[Samba.git] / python / samba / tests / subunitrun.py
blob88d68faa65c5a7c22d99cc078728ff6e56901a3f
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
6 # YOURMODULE".
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
11 # script.
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.
32 import signal
33 signal.signal(signal.SIGINT, signal.SIG_DFL)
35 import optparse
36 import sys
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.',
48 action="store_true")
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):
56 if args is None:
57 args = []
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)