mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 23:05:42 +00:00
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:
parent
e4bd080c0b
commit
bc3a6199df
@ -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
|
||||
|
||||
|
@ -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'))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user