MCPcopy Index your code
hub / github.com/python/cpython / test_subparser_parents_mutex

Method test_subparser_parents_mutex

Lib/test/test_argparse.py:3231–3248  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3229 NS(a='3', b='1', d='2', e='4'))
3230
3231 def test_subparser_parents_mutex(self):
3232 parser = ErrorRaisingArgumentParser()
3233 subparsers = parser.add_subparsers()
3234 parents = [self.ab_mutex_parent]
3235 abc_parser = subparsers.add_parser('foo', parents=parents)
3236 c_group = abc_parser.add_argument_group('c_group')
3237 c_group.add_argument('c')
3238 parents = [self.wxyz_parent, self.ab_mutex_parent]
3239 wxyzabe_parser = subparsers.add_parser('bar', parents=parents)
3240 wxyzabe_parser.add_argument('e')
3241 self.assertEqual(parser.parse_args('foo -a 4'.split()),
3242 NS(a=True, b=False, c='4'))
3243 self.assertEqual(parser.parse_args('bar -b --w 2 3 4'.split()),
3244 NS(a=False, b=True, w='2', y=None, z='3', e='4'))
3245 self.assertArgumentParserError(
3246 parser.parse_args, 'foo -a -b 4'.split())
3247 self.assertArgumentParserError(
3248 parser.parse_args, 'bar -b -a 4'.split())
3249
3250 def test_parent_help(self):
3251 parents = [self.abcd_parent, self.wxyz_parent]

Callers

nothing calls this directly

Calls 10

parse_argsMethod · 0.95
add_subparsersMethod · 0.80
add_parserMethod · 0.80
NSClass · 0.70
add_argument_groupMethod · 0.45
add_argumentMethod · 0.45
assertEqualMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected