~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_options.py

  • Committer: Kent Gibson
  • Date: 2007-03-11 13:44:18 UTC
  • mfrom: (2334 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2350.
  • Revision ID: warthog618@gmail.com-20070311134418-nu57arul94zawbj4
merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
157
157
        opts, args = self.parse(options, ['--two', '--one',
158
158
                                          '--format', 'two'])
159
159
        self.assertEqual({'format':'two'}, opts)
 
160
        options = [option.RegistryOption('format', '', registry, str,
 
161
                   enum_switch=False)]
 
162
        self.assertRaises(errors.BzrCommandError, self.parse, options,
 
163
                          ['--format', 'two'])
160
164
 
161
165
    def test_registry_converter(self):
162
166
        options = [option.RegistryOption('format', '',
165
169
        self.assertIsInstance(opts.format.repository_format,
166
170
                              knitrepo.RepositoryFormatKnit1)
167
171
 
 
172
    def test_from_kwargs(self):
 
173
        my_option = option.RegistryOption.from_kwargs('my-option',
 
174
            help='test option', short='be short', be_long='go long')
 
175
        self.assertEqual(['my-option'],
 
176
            [x[0] for x in my_option.iter_switches()])
 
177
        my_option = option.RegistryOption.from_kwargs('my-option',
 
178
            help='test option', title="My option", short='be short',
 
179
            be_long='go long', value_switches=True)
 
180
        self.assertEqual(['my-option', 'be-long', 'short'],
 
181
            [x[0] for x in my_option.iter_switches()])
 
182
 
168
183
    def test_help(self):
169
184
        registry = bzrdir.BzrDirFormatRegistry()
170
185
        registry.register_metadir('one', 'RepositoryFormat7', 'one help')