예제 #1
0
 def test_multiple_groups(self):
     groups = (["one", "two", "three"], ["foo", "bar", "baz"], ["qux", "bad", "morebad"])
     # This is fine.
     parsed = FakeParsedArgs(foo="foo", bar="bar", baz="baz")
     utils.validate_mutually_exclusive(parsed, *groups)
     # But this is bad.
     parsed = FakeParsedArgs(foo="one", bar=None, qux="three")
     with self.assertRaises(ValueError):
         utils.validate_mutually_exclusive(parsed, *groups)
예제 #2
0
 def test_multiple_groups(self):
     groups = (['one', 'two', 'three'], ['foo', 'bar', 'baz'],
               ['qux', 'bad', 'morebad'])
     # This is fine.
     parsed = FakeParsedArgs(foo='foo', bar='bar', baz='baz')
     utils.validate_mutually_exclusive(parsed, *groups)
     # But this is bad.
     parsed = FakeParsedArgs(foo='one', bar=None, qux='three')
     with self.assertRaises(ValueError):
         utils.validate_mutually_exclusive(parsed, *groups)
예제 #3
0
 def test_multiple_groups(self):
     groups = (['one', 'two', 'three'], ['foo', 'bar',
                                         'baz'], ['qux', 'bad', 'morebad'])
     # This is fine.
     parsed = FakeParsedArgs(foo='foo', bar='bar', baz='baz')
     utils.validate_mutually_exclusive(parsed, *groups)
     # But this is bad.
     parsed = FakeParsedArgs(foo='one', bar=None, qux='three')
     with self.assertRaises(ValueError):
         utils.validate_mutually_exclusive(parsed, *groups)
예제 #4
0
 def test_two_single_groups(self):
     # The most basic example of mutually exclusive args.
     # If foo is specified, but bar is not, then we're fine.
     parsed = FakeParsedArgs(foo='one', bar=None)
     utils.validate_mutually_exclusive(parsed, ['foo'], ['bar'])
     # If bar is specified and foo is not, then we're fine.
     parsed = FakeParsedArgs(foo=None, bar='one')
     utils.validate_mutually_exclusive(parsed, ['foo'], ['bar'])
     # But if we specify both foo and bar then we get an error.
     parsed = FakeParsedArgs(foo='one', bar='two')
     with self.assertRaises(ValueError):
         utils.validate_mutually_exclusive(parsed, ['foo'], ['bar'])
예제 #5
0
 def test_two_single_groups(self):
     # The most basic example of mutually exclusive args.
     # If foo is specified, but bar is not, then we're fine.
     parsed = FakeParsedArgs(foo='one', bar=None)
     utils.validate_mutually_exclusive(parsed, ['foo'], ['bar'])
     # If bar is specified and foo is not, then we're fine.
     parsed = FakeParsedArgs(foo=None, bar='one')
     utils.validate_mutually_exclusive(parsed, ['foo'], ['bar'])
     # But if we specify both foo and bar then we get an error.
     parsed = FakeParsedArgs(foo='one', bar='two')
     with self.assertRaises(ValueError):
         utils.validate_mutually_exclusive(parsed, ['foo'], ['bar'])