~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_options.py

  • Committer: Jelmer Vernooij
  • Date: 2011-08-19 22:34:02 UTC
  • mto: This revision was merged to the branch mainline in revision 6089.
  • Revision ID: jelmer@samba.org-20110819223402-wjywqb0fa1xxx522
Use get_transport_from_{url,path} in more places.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
 
1
# Copyright (C) 2005-2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
16
 
 
17
import re
16
18
 
17
19
from bzrlib import (
18
 
    builtins,
19
20
    bzrdir,
 
21
    commands,
 
22
    controldir,
20
23
    errors,
21
24
    option,
22
 
    repository,
23
 
    symbol_versioning,
 
25
    registry,
24
26
    )
25
 
from bzrlib.builtins import cmd_commit, cmd_log, cmd_status
26
 
from bzrlib.commands import Command, parse_args
 
27
from bzrlib.builtins import cmd_commit
 
28
from bzrlib.commands import parse_args
27
29
from bzrlib.tests import TestCase
28
30
from bzrlib.repofmt import knitrepo
29
31
 
 
32
 
30
33
def parse(options, args):
31
34
    parser = option.get_optparser(dict((o.name, o) for o in options))
32
35
    return parser.parse_args(args)
33
36
 
 
37
 
34
38
class OptionTests(TestCase):
35
39
    """Command-line option tests"""
36
40
 
37
41
    def test_parse_args(self):
38
42
        """Option parser"""
39
 
        eq = self.assertEquals
40
 
        eq(parse_args(cmd_commit(), ['--help']),
41
 
           ([], {'help': True}))
42
 
        eq(parse_args(cmd_commit(), ['--message=biter']),
43
 
           ([], {'message': 'biter'}))
44
 
        ## eq(parse_args(cmd_log(),  '-r 500'.split()),
45
 
        ##   ([], {'revision': RevisionSpec_int(500)}))
 
43
        # XXX: Using cmd_commit makes these tests overly sensitive to changes
 
44
        # to cmd_commit, when they are meant to be about option parsing in
 
45
        # general.
 
46
        self.assertEqual(parse_args(cmd_commit(), ['--help']),
 
47
           ([], {'author': [], 'exclude': [], 'fixes': [], 'help': True}))
 
48
        self.assertEqual(parse_args(cmd_commit(), ['--message=biter']),
 
49
           ([], {'author': [], 'exclude': [], 'fixes': [], 'message': 'biter'}))
46
50
 
47
51
    def test_no_more_opts(self):
48
52
        """Terminated options"""
49
 
        self.assertEquals(parse_args(cmd_commit(), ['--', '-file-with-dashes']),
50
 
                          (['-file-with-dashes'], {}))
 
53
        self.assertEqual(parse_args(cmd_commit(), ['--', '-file-with-dashes']),
 
54
                          (['-file-with-dashes'], {'author': [], 'exclude': [], 'fixes': []}))
51
55
 
52
56
    def test_option_help(self):
53
57
        """Options have help strings."""
54
 
        out, err = self.run_bzr_captured(['commit', '--help'])
55
 
        self.assertContainsRe(out, r'--file(.|\n)*file containing commit'
56
 
                                   ' message')
 
58
        out, err = self.run_bzr('commit --help')
 
59
        self.assertContainsRe(out,
 
60
                r'--file(.|\n)*Take commit message from this file\.')
57
61
        self.assertContainsRe(out, r'-h.*--help')
58
62
 
59
63
    def test_option_help_global(self):
60
64
        """Global options have help strings."""
61
 
        out, err = self.run_bzr_captured(['help', 'status'])
62
 
        self.assertContainsRe(out, r'--show-ids.*show internal object')
 
65
        out, err = self.run_bzr('help status')
 
66
        self.assertContainsRe(out, r'--show-ids.*Show internal object.')
63
67
 
64
68
    def test_option_arg_help(self):
65
69
        """Help message shows option arguments."""
66
 
        out, err = self.run_bzr_captured(['help', 'commit'])
67
 
        self.assertEquals(err, '')
 
70
        out, err = self.run_bzr('help commit')
 
71
        self.assertEqual(err, '')
68
72
        self.assertContainsRe(out, r'--file[ =]MSGFILE')
69
73
 
70
74
    def test_unknown_short_opt(self):
71
 
        out, err = self.run_bzr_captured(['help', '-r'], retcode=3)
 
75
        out, err = self.run_bzr('help -r', retcode=3)
72
76
        self.assertContainsRe(err, r'no such option')
73
77
 
74
 
    def test_get_short_name(self):
75
 
        file_opt = option.Option.OPTIONS['file']
76
 
        self.assertEquals(file_opt.short_name(), 'F')
77
 
        force_opt = option.Option.OPTIONS['force']
78
 
        self.assertEquals(force_opt.short_name(), None)
79
 
 
80
78
    def test_set_short_name(self):
81
79
        o = option.Option('wiggle')
82
80
        o.set_short_name('w')
83
81
        self.assertEqual(o.short_name(), 'w')
84
82
 
85
 
    def test_old_short_names(self):
86
 
        # test the deprecated method for getting and setting short option
87
 
        # names
88
 
        expected_warning = (
89
 
            "access to SHORT_OPTIONS was deprecated in version 0.14."
90
 
            " Set the short option name when constructing the Option.",
91
 
            DeprecationWarning, 2)
92
 
        _warnings = []
93
 
        def capture_warning(message, category, stacklevel=None):
94
 
            _warnings.append((message, category, stacklevel))
95
 
        old_warning_method = symbol_versioning.warn
96
 
        try:
97
 
            # an example of the kind of thing plugins might want to do through
98
 
            # the old interface - make a new option and then give it a short
99
 
            # name.
100
 
            symbol_versioning.set_warning_method(capture_warning)
101
 
            example_opt = option.Option('example', help='example option')
102
 
            option.Option.SHORT_OPTIONS['w'] = example_opt
103
 
            self.assertEqual(example_opt.short_name(), 'w')
104
 
            self.assertEqual([expected_warning], _warnings)
105
 
            # now check that it can actually be parsed with the registered
106
 
            # value
107
 
            opts, args = parse([example_opt], ['-w', 'foo'])
108
 
            self.assertEqual(opts.example, True)
109
 
            self.assertEqual(args, ['foo'])
110
 
        finally:
111
 
            symbol_versioning.set_warning_method(old_warning_method)
112
 
 
113
83
    def test_allow_dash(self):
114
84
        """Test that we can pass a plain '-' as an argument."""
115
 
        self.assertEqual((['-'], {}), parse_args(cmd_commit(), ['-']))
 
85
        self.assertEqual((['-']), parse_args(cmd_commit(), ['-'])[0])
116
86
 
117
87
    def parse(self, options, args):
118
88
        parser = option.get_optparser(dict((o.name, o) for o in options))
123
93
        opts, args = self.parse(options, ['--no-hello', '--hello'])
124
94
        self.assertEqual(True, opts.hello)
125
95
        opts, args = self.parse(options, [])
126
 
        self.assertEqual(option.OptionParser.DEFAULT_VALUE, opts.hello)
 
96
        self.assertFalse(hasattr(opts, 'hello'))
127
97
        opts, args = self.parse(options, ['--hello', '--no-hello'])
128
98
        self.assertEqual(False, opts.hello)
129
99
        options = [option.Option('number', type=int)]
134
104
        self.assertRaises(errors.BzrCommandError, self.parse, options,
135
105
                          ['--no-number'])
136
106
 
 
107
    def test_is_hidden(self):
 
108
        self.assertTrue(option.Option('foo', hidden=True).is_hidden('foo'))
 
109
        self.assertFalse(option.Option('foo', hidden=False).is_hidden('foo'))
 
110
 
137
111
    def test_registry_conversion(self):
138
 
        registry = bzrdir.BzrDirFormatRegistry()
139
 
        registry.register_metadir('one', 'RepositoryFormat7', 'one help')
140
 
        registry.register_metadir('two', 'RepositoryFormatKnit1', 'two help')
 
112
        registry = controldir.ControlDirFormatRegistry()
 
113
        bzrdir.register_metadir(registry, 'one', 'RepositoryFormat7', 'one help')
 
114
        bzrdir.register_metadir(registry, 'two', 'RepositoryFormatKnit1', 'two help')
 
115
        bzrdir.register_metadir(registry, 'hidden', 'RepositoryFormatKnit1',
 
116
            'two help', hidden=True)
141
117
        registry.set_default('one')
142
118
        options = [option.RegistryOption('format', '', registry, str)]
143
119
        opts, args = self.parse(options, ['--format', 'one'])
157
133
        opts, args = self.parse(options, ['--two', '--one',
158
134
                                          '--format', 'two'])
159
135
        self.assertEqual({'format':'two'}, opts)
 
136
        options = [option.RegistryOption('format', '', registry, str,
 
137
                   enum_switch=False)]
 
138
        self.assertRaises(errors.BzrCommandError, self.parse, options,
 
139
                          ['--format', 'two'])
 
140
 
 
141
    def test_override(self):
 
142
        options = [option.Option('hello', type=str),
 
143
                   option.Option('hi', type=str, param_name='hello')]
 
144
        opts, args = self.parse(options, ['--hello', 'a', '--hello', 'b'])
 
145
        self.assertEqual('b', opts.hello)
 
146
        opts, args = self.parse(options, ['--hello', 'b', '--hello', 'a'])
 
147
        self.assertEqual('a', opts.hello)
 
148
        opts, args = self.parse(options, ['--hello', 'a', '--hi', 'b'])
 
149
        self.assertEqual('b', opts.hello)
 
150
        opts, args = self.parse(options, ['--hi', 'b', '--hello', 'a'])
 
151
        self.assertEqual('a', opts.hello)
160
152
 
161
153
    def test_registry_converter(self):
162
154
        options = [option.RegistryOption('format', '',
165
157
        self.assertIsInstance(opts.format.repository_format,
166
158
                              knitrepo.RepositoryFormatKnit1)
167
159
 
 
160
    def test_lazy_registry(self):
 
161
        options = [option.RegistryOption('format', '',
 
162
                   lazy_registry=('bzrlib.bzrdir','format_registry'),
 
163
                   converter=str)]
 
164
        opts, args = self.parse(options, ['--format', 'knit'])
 
165
        self.assertEqual({'format': 'knit'}, opts)
 
166
        self.assertRaises(
 
167
            errors.BadOptionValue, self.parse, options, ['--format', 'BAD'])
 
168
 
 
169
    def test_from_kwargs(self):
 
170
        my_option = option.RegistryOption.from_kwargs('my-option',
 
171
            help='test option', short='be short', be_long='go long')
 
172
        self.assertEqual(['my-option'],
 
173
            [x[0] for x in my_option.iter_switches()])
 
174
        my_option = option.RegistryOption.from_kwargs('my-option',
 
175
            help='test option', title="My option", short='be short',
 
176
            be_long='go long', value_switches=True)
 
177
        self.assertEqual(['my-option', 'be-long', 'short'],
 
178
            [x[0] for x in my_option.iter_switches()])
 
179
        self.assertEqual('test option', my_option.help)
 
180
 
168
181
    def test_help(self):
169
 
        registry = bzrdir.BzrDirFormatRegistry()
170
 
        registry.register_metadir('one', 'RepositoryFormat7', 'one help')
171
 
        registry.register_metadir('two',
 
182
        registry = controldir.ControlDirFormatRegistry()
 
183
        bzrdir.register_metadir(registry, 'one', 'RepositoryFormat7', 'one help')
 
184
        bzrdir.register_metadir(registry, 'two',
172
185
            'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
173
186
            'two help',
174
187
            )
 
188
        bzrdir.register_metadir(registry, 'hidden', 'RepositoryFormat7', 'hidden help',
 
189
            hidden=True)
175
190
        registry.set_default('one')
176
191
        options = [option.RegistryOption('format', 'format help', registry,
177
192
                   str, value_switches=True, title='Formats')]
180
195
        self.assertContainsRe(value, 'format.*format help')
181
196
        self.assertContainsRe(value, 'one.*one help')
182
197
        self.assertContainsRe(value, 'Formats:\n *--format')
 
198
        self.assertNotContainsRe(value, 'hidden help')
183
199
 
184
200
    def test_iter_switches(self):
185
201
        opt = option.Option('hello', help='fg')
191
207
        opt = option.Option('hello', help='fg', type=int, argname='gar')
192
208
        self.assertEqual(list(opt.iter_switches()),
193
209
                         [('hello', None, 'GAR', 'fg')])
194
 
        registry = bzrdir.BzrDirFormatRegistry()
195
 
        registry.register_metadir('one', 'RepositoryFormat7', 'one help')
196
 
        registry.register_metadir('two',
 
210
        registry = controldir.ControlDirFormatRegistry()
 
211
        bzrdir.register_metadir(registry, 'one', 'RepositoryFormat7', 'one help')
 
212
        bzrdir.register_metadir(registry, 'two',
197
213
                'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
198
214
                'two help',
199
215
                )
211
227
                          ('two', None, None, 'two help'),
212
228
                          ])
213
229
 
214
 
#     >>> parse_args('log -r 500'.split())
215
 
#     (['log'], {'revision': [<RevisionSpec_int 500>]})
216
 
#     >>> parse_args('log -r500..600'.split())
217
 
#     (['log'], {'revision': [<RevisionSpec_int 500>, <RevisionSpec_int 600>]})
218
 
#     >>> parse_args('log -vr500..600'.split())
219
 
#     (['log'], {'verbose': True, 'revision': [<RevisionSpec_int 500>, <RevisionSpec_int 600>]})
220
 
#     >>> parse_args('log -rrevno:500..600'.split()) #the r takes an argument
221
 
#     (['log'], {'revision': [<RevisionSpec_revno revno:500>, <RevisionSpec_int 600>]})
 
230
    def test_option_callback_bool(self):
 
231
        "Test booleans get True and False passed correctly to a callback."""
 
232
        cb_calls = []
 
233
        def cb(option, name, value, parser):
 
234
            cb_calls.append((option,name,value,parser))
 
235
        options = [option.Option('hello', custom_callback=cb)]
 
236
        opts, args = self.parse(options, ['--hello', '--no-hello'])
 
237
        self.assertEqual(2, len(cb_calls))
 
238
        opt,name,value,parser = cb_calls[0]
 
239
        self.assertEqual('hello', name)
 
240
        self.assertTrue(value)
 
241
        opt,name,value,parser = cb_calls[1]
 
242
        self.assertEqual('hello', name)
 
243
        self.assertFalse(value)
 
244
 
 
245
    def test_option_callback_str(self):
 
246
        """Test callbacks work for string options both long and short."""
 
247
        cb_calls = []
 
248
        def cb(option, name, value, parser):
 
249
            cb_calls.append((option,name,value,parser))
 
250
        options = [option.Option('hello', type=str, custom_callback=cb,
 
251
            short_name='h')]
 
252
        opts, args = self.parse(options, ['--hello', 'world', '-h', 'mars'])
 
253
        self.assertEqual(2, len(cb_calls))
 
254
        opt,name,value,parser = cb_calls[0]
 
255
        self.assertEqual('hello', name)
 
256
        self.assertEqual('world', value)
 
257
        opt,name,value,parser = cb_calls[1]
 
258
        self.assertEqual('hello', name)
 
259
        self.assertEqual('mars', value)
 
260
 
 
261
 
 
262
class TestListOptions(TestCase):
 
263
    """Tests for ListOption, used to specify lists on the command-line."""
 
264
 
 
265
    def parse(self, options, args):
 
266
        parser = option.get_optparser(dict((o.name, o) for o in options))
 
267
        return parser.parse_args(args)
 
268
 
 
269
    def test_list_option(self):
 
270
        options = [option.ListOption('hello', type=str)]
 
271
        opts, args = self.parse(options, ['--hello=world', '--hello=sailor'])
 
272
        self.assertEqual(['world', 'sailor'], opts.hello)
 
273
 
 
274
    def test_list_option_with_dash(self):
 
275
        options = [option.ListOption('with-dash', type=str)]
 
276
        opts, args = self.parse(options, ['--with-dash=world',
 
277
                                          '--with-dash=sailor'])
 
278
        self.assertEqual(['world', 'sailor'], opts.with_dash)
 
279
 
 
280
    def test_list_option_no_arguments(self):
 
281
        options = [option.ListOption('hello', type=str)]
 
282
        opts, args = self.parse(options, [])
 
283
        self.assertEqual([], opts.hello)
 
284
 
 
285
    def test_list_option_with_int_type(self):
 
286
        options = [option.ListOption('hello', type=int)]
 
287
        opts, args = self.parse(options, ['--hello=2', '--hello=3'])
 
288
        self.assertEqual([2, 3], opts.hello)
 
289
 
 
290
    def test_list_option_with_int_type_can_be_reset(self):
 
291
        options = [option.ListOption('hello', type=int)]
 
292
        opts, args = self.parse(options, ['--hello=2', '--hello=3',
 
293
                                          '--hello=-', '--hello=5'])
 
294
        self.assertEqual([5], opts.hello)
 
295
 
 
296
    def test_list_option_can_be_reset(self):
 
297
        """Passing an option of '-' to a list option should reset the list."""
 
298
        options = [option.ListOption('hello', type=str)]
 
299
        opts, args = self.parse(
 
300
            options, ['--hello=a', '--hello=b', '--hello=-', '--hello=c'])
 
301
        self.assertEqual(['c'], opts.hello)
 
302
 
 
303
    def test_option_callback_list(self):
 
304
        """Test callbacks work for list options."""
 
305
        cb_calls = []
 
306
        def cb(option, name, value, parser):
 
307
            # Note that the value is a reference so copy to keep it
 
308
            cb_calls.append((option,name,value[:],parser))
 
309
        options = [option.ListOption('hello', type=str, custom_callback=cb)]
 
310
        opts, args = self.parse(options, ['--hello=world', '--hello=mars',
 
311
            '--hello=-'])
 
312
        self.assertEqual(3, len(cb_calls))
 
313
        opt,name,value,parser = cb_calls[0]
 
314
        self.assertEqual('hello', name)
 
315
        self.assertEqual(['world'], value)
 
316
        opt,name,value,parser = cb_calls[1]
 
317
        self.assertEqual('hello', name)
 
318
        self.assertEqual(['world', 'mars'], value)
 
319
        opt,name,value,parser = cb_calls[2]
 
320
        self.assertEqual('hello', name)
 
321
        self.assertEqual([], value)
 
322
 
 
323
    def test_list_option_param_name(self):
 
324
        """Test list options can have their param_name set."""
 
325
        options = [option.ListOption('hello', type=str, param_name='greeting')]
 
326
        opts, args = self.parse(
 
327
            options, ['--hello=world', '--hello=sailor'])
 
328
        self.assertEqual(['world', 'sailor'], opts.greeting)
 
329
 
 
330
 
 
331
class TestOptionDefinitions(TestCase):
 
332
    """Tests for options in the Bazaar codebase."""
 
333
 
 
334
    def get_builtin_command_options(self):
 
335
        g = []
 
336
        for cmd_name in sorted(commands.all_command_names()):
 
337
            cmd = commands.get_cmd_object(cmd_name)
 
338
            for opt_name, opt in sorted(cmd.options().items()):
 
339
                g.append((cmd_name, opt))
 
340
        return g
 
341
 
 
342
    def test_global_options_used(self):
 
343
        # In the distant memory, options could only be declared globally.  Now
 
344
        # we prefer to declare them in the command, unless like -r they really
 
345
        # are used very widely with the exact same meaning.  So this checks
 
346
        # for any that should be garbage collected.
 
347
        g = dict(option.Option.OPTIONS.items())
 
348
        used_globals = {}
 
349
        msgs = []
 
350
        for cmd_name in sorted(commands.all_command_names()):
 
351
            cmd = commands.get_cmd_object(cmd_name)
 
352
            for option_or_name in sorted(cmd.takes_options):
 
353
                if not isinstance(option_or_name, basestring):
 
354
                    self.assertIsInstance(option_or_name, option.Option)
 
355
                elif not option_or_name in g:
 
356
                    msgs.append("apparent reference to undefined "
 
357
                        "global option %r from %r"
 
358
                        % (option_or_name, cmd))
 
359
                else:
 
360
                    used_globals.setdefault(option_or_name, []).append(cmd_name)
 
361
        unused_globals = set(g.keys()) - set(used_globals.keys())
 
362
        # not enforced because there might be plugins that use these globals
 
363
        ## for option_name in sorted(unused_globals):
 
364
        ##    msgs.append("unused global option %r" % option_name)
 
365
        ## for option_name, cmds in sorted(used_globals.items()):
 
366
        ##     if len(cmds) <= 1:
 
367
        ##         msgs.append("global option %r is only used by %r"
 
368
        ##                 % (option_name, cmds))
 
369
        if msgs:
 
370
            self.fail("problems with global option definitions:\n"
 
371
                    + '\n'.join(msgs))
 
372
 
 
373
    def test_option_grammar(self):
 
374
        msgs = []
 
375
        # Option help should be written in sentence form, and have a final
 
376
        # period and be all on a single line, because the display code will
 
377
        # wrap it.
 
378
        option_re = re.compile(r'^[A-Z][^\n]+\.$')
 
379
        for scope, opt in self.get_builtin_command_options():
 
380
            if not opt.help:
 
381
                msgs.append('%-16s %-16s %s' %
 
382
                       ((scope or 'GLOBAL'), opt.name, 'NO HELP'))
 
383
            elif not option_re.match(opt.help):
 
384
                msgs.append('%-16s %-16s %s' %
 
385
                        ((scope or 'GLOBAL'), opt.name, opt.help))
 
386
        if msgs:
 
387
            self.fail("The following options don't match the style guide:\n"
 
388
                    + '\n'.join(msgs))
 
389
 
 
390
    def test_is_hidden(self):
 
391
        registry = controldir.ControlDirFormatRegistry()
 
392
        bzrdir.register_metadir(registry, 'hidden', 'HiddenFormat',
 
393
            'hidden help text', hidden=True)
 
394
        bzrdir.register_metadir(registry, 'visible', 'VisibleFormat',
 
395
            'visible help text', hidden=False)
 
396
        format = option.RegistryOption('format', '', registry, str)
 
397
        self.assertTrue(format.is_hidden('hidden'))
 
398
        self.assertFalse(format.is_hidden('visible'))
 
399
 
 
400
    def test_short_name(self):
 
401
        registry = controldir.ControlDirFormatRegistry()
 
402
        opt = option.RegistryOption('format', help='', registry=registry)
 
403
        self.assertEquals(None, opt.short_name())
 
404
        opt = option.RegistryOption('format', short_name='F', help='',
 
405
            registry=registry)
 
406
        self.assertEquals('F', opt.short_name())
 
407
 
 
408
    def test_option_custom_help(self):
 
409
        the_opt = option.Option.OPTIONS['help']
 
410
        orig_help = the_opt.help[:]
 
411
        my_opt = option.custom_help('help', 'suggest lottery numbers')
 
412
        # Confirm that my_opt has my help and the original is unchanged
 
413
        self.assertEqual('suggest lottery numbers', my_opt.help)
 
414
        self.assertEqual(orig_help, the_opt.help)
 
415
 
 
416
    def test_short_value_switches(self):
 
417
        reg = registry.Registry()
 
418
        reg.register('short', 'ShortChoice')
 
419
        reg.register('long', 'LongChoice')
 
420
        ropt = option.RegistryOption('choice', '', reg, value_switches=True,
 
421
            short_value_switches={'short': 's'})
 
422
        opts, args = parse([ropt], ['--short'])
 
423
        self.assertEqual('ShortChoice', opts.choice)
 
424
        opts, args = parse([ropt], ['-s'])
 
425
        self.assertEqual('ShortChoice', opts.choice)
 
426
 
 
427
 
 
428
class TestVerboseQuietLinkage(TestCase):
 
429
 
 
430
    def check(self, parser, level, args):
 
431
        option._verbosity_level = 0
 
432
        opts, args = parser.parse_args(args)
 
433
        self.assertEqual(level, option._verbosity_level)
 
434
 
 
435
    def test_verbose_quiet_linkage(self):
 
436
        parser = option.get_optparser(option.Option.STD_OPTIONS)
 
437
        self.check(parser, 0, [])
 
438
        self.check(parser, 1, ['-v'])
 
439
        self.check(parser, 2, ['-v', '-v'])
 
440
        self.check(parser, -1, ['-q'])
 
441
        self.check(parser, -2, ['-qq'])
 
442
        self.check(parser, -1, ['-v', '-v', '-q'])
 
443
        self.check(parser, 2, ['-q', '-v', '-v'])
 
444
        self.check(parser, 0, ['--no-verbose'])
 
445
        self.check(parser, 0, ['-v', '-q', '--no-quiet'])