зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1363811 - Change TestConfigure.test_depends_or to test more cases. r=cmanchester+432261
Also, test the results match what a normal "or" of the returned values would be. This makes it clearer how the feature is meant to work.
This commit is contained in:
Родитель
57258bd4bf
Коммит
fafb6f8f44
|
@ -1292,34 +1292,39 @@ class TestConfigure(unittest.TestCase):
|
||||||
option('--foo', nargs=1, help='foo')
|
option('--foo', nargs=1, help='foo')
|
||||||
@depends('--foo')
|
@depends('--foo')
|
||||||
def foo(value):
|
def foo(value):
|
||||||
return value or None
|
return value or 0
|
||||||
|
|
||||||
option('--bar', nargs=1, help='bar')
|
option('--bar', nargs=1, help='bar')
|
||||||
@depends('--bar')
|
@depends('--bar')
|
||||||
def bar(value):
|
def bar(value):
|
||||||
|
return value or ''
|
||||||
|
|
||||||
|
option('--baz', nargs=1, help='baz')
|
||||||
|
@depends('--baz')
|
||||||
|
def baz(value):
|
||||||
return value
|
return value
|
||||||
|
|
||||||
set_config('FOOBAR', foo | bar)
|
set_config('FOOBAR', foo | bar)
|
||||||
|
set_config('FOOBARBAZ', foo | bar | baz)
|
||||||
'''):
|
'''):
|
||||||
config = self.get_config()
|
for foo_opt, foo_value in (
|
||||||
self.assertEqual(config, {
|
('', 0),
|
||||||
'FOOBAR': NegativeOptionValue(),
|
('--foo=foo', PositiveOptionValue(('foo',)))
|
||||||
})
|
):
|
||||||
|
for bar_opt, bar_value in (
|
||||||
config = self.get_config(['--foo=foo'])
|
('', ''),
|
||||||
self.assertEqual(config, {
|
('--bar=bar', PositiveOptionValue(('bar',)))
|
||||||
'FOOBAR': PositiveOptionValue(('foo',)),
|
):
|
||||||
})
|
for baz_opt, baz_value in (
|
||||||
|
('', NegativeOptionValue()),
|
||||||
config = self.get_config(['--bar=bar'])
|
('--baz=baz', PositiveOptionValue(('baz',)))
|
||||||
self.assertEqual(config, {
|
):
|
||||||
'FOOBAR': PositiveOptionValue(('bar',)),
|
config = self.get_config(
|
||||||
})
|
[x for x in (foo_opt, bar_opt, baz_opt) if x])
|
||||||
|
self.assertEqual(config, {
|
||||||
config = self.get_config(['--foo=foo', '--bar=bar'])
|
'FOOBAR': foo_value or bar_value,
|
||||||
self.assertEqual(config, {
|
'FOOBARBAZ': foo_value or bar_value or baz_value,
|
||||||
'FOOBAR': PositiveOptionValue(('foo',)),
|
})
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Загрузка…
Ссылка в новой задаче