25
25
from bzrlib.builtins import cmd_commit, cmd_log, cmd_status
26
26
from bzrlib.commands import Command, parse_args
27
27
from bzrlib.tests import TestCase
28
from bzrlib.repofmt import knitrepo
29
30
def parse(options, args):
30
31
parser = option.get_optparser(dict((o.name, o) for o in options))
160
161
def test_registry_converter(self):
161
162
options = [option.RegistryOption('format', '',
162
bzrdir.format_registry, builtins.get_format_type)]
163
bzrdir.format_registry, bzrdir.format_registry.make_bzrdir)]
163
164
opts, args = self.parse(options, ['--format', 'knit'])
164
165
self.assertIsInstance(opts.format.repository_format,
165
repository.RepositoryFormatKnit1)
166
knitrepo.RepositoryFormatKnit1)
167
168
def test_help(self):
168
169
registry = bzrdir.BzrDirFormatRegistry()
169
170
registry.register_metadir('one', 'RepositoryFormat7', 'one help')
170
registry.register_metadir('two', 'RepositoryFormatKnit1', 'two help')
171
registry.register_metadir('two',
172
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
171
175
registry.set_default('one')
172
176
options = [option.RegistryOption('format', 'format help', registry,
173
str, value_switches=True)]
177
str, value_switches=True, title='Formats')]
174
178
parser = option.get_optparser(dict((o.name, o) for o in options))
175
179
value = parser.format_option_help()
176
180
self.assertContainsRe(value, 'format.*format help')
177
181
self.assertContainsRe(value, 'one.*one help')
182
self.assertContainsRe(value, 'Formats:\n *--format')
179
184
def test_iter_switches(self):
180
185
opt = option.Option('hello', help='fg')
188
193
[('hello', None, 'GAR', 'fg')])
189
194
registry = bzrdir.BzrDirFormatRegistry()
190
195
registry.register_metadir('one', 'RepositoryFormat7', 'one help')
191
registry.register_metadir('two', 'RepositoryFormatKnit1', 'two help')
196
registry.register_metadir('two',
197
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
192
200
registry.set_default('one')
193
201
opt = option.RegistryOption('format', 'format help', registry,
194
202
value_switches=False)