74
74
out, err = self.run_bzr('help -r', retcode=3)
75
75
self.assertContainsRe(err, r'no such option')
77
def test_get_short_name(self):
78
file_opt = option.Option.OPTIONS['file']
79
self.assertEquals(file_opt.short_name(), 'F')
80
force_opt = option.Option.OPTIONS['force']
81
self.assertEquals(force_opt.short_name(), None)
83
77
def test_set_short_name(self):
84
78
o = option.Option('wiggle')
85
79
o.set_short_name('w')
86
80
self.assertEqual(o.short_name(), 'w')
88
def test_old_short_names(self):
89
# test the deprecated method for getting and setting short option
92
"access to SHORT_OPTIONS was deprecated in version 0.14."
93
" Set the short option name when constructing the Option.",
94
DeprecationWarning, 2)
96
def capture_warning(message, category, stacklevel=None):
97
_warnings.append((message, category, stacklevel))
98
old_warning_method = symbol_versioning.warn
100
# an example of the kind of thing plugins might want to do through
101
# the old interface - make a new option and then give it a short
103
symbol_versioning.set_warning_method(capture_warning)
104
example_opt = option.Option('example', help='example option')
105
option.Option.SHORT_OPTIONS['w'] = example_opt
106
self.assertEqual(example_opt.short_name(), 'w')
107
self.assertEqual([expected_warning], _warnings)
108
# now check that it can actually be parsed with the registered
110
opts, args = parse([example_opt], ['-w', 'foo'])
111
self.assertEqual(opts.example, True)
112
self.assertEqual(args, ['foo'])
114
symbol_versioning.set_warning_method(old_warning_method)
116
82
def test_allow_dash(self):
117
83
"""Test that we can pass a plain '-' as an argument."""