Bug 1257104 - Allow options with choices and possibly no given values. r=ted

While rare, this is something we support for e.g. --enable-eme, where it
can be either given with no values, "adobe", some future other EME GMP
adapter names, or a combination of them.
This commit is contained in:
Mike Hommey 2016-03-16 16:44:00 +09:00
parent e4bd080c0b
commit bc3a6199df
2 changed files with 0 additions and 13 deletions

View File

@ -219,10 +219,6 @@ class Option(object):
maxargs = self.maxargs
if len(choices) < maxargs and maxargs != sys.maxint:
raise InvalidOptionError('Not enough `choices` for `nargs`')
if self.minargs == 0:
raise InvalidOptionError(
'%s is not a valid `nargs` when `choices` are given'
% str(nargs))
self.choices = choices
self.help = help

View File

@ -158,18 +158,9 @@ class TestOption(unittest.TestCase):
self.assertEquals(Option(env='FOO').option, 'FOO')
def test_option_choices(self):
with self.assertRaises(InvalidOptionError):
Option('--option', nargs=0, choices=('a', 'b'))
with self.assertRaises(InvalidOptionError):
Option('--option', nargs=3, choices=('a', 'b'))
with self.assertRaises(InvalidOptionError):
Option('--option', nargs='?', choices=('a', 'b'))
with self.assertRaises(InvalidOptionError):
Option('--option', nargs='*', choices=('a', 'b'))
with self.assertRaises(InvalidOptionError):
Option('--without-option', nargs=1, choices=('a', 'b'))