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

Method test_groups_parents

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

Source from the content-addressed store, hash-verified

3271 '''))
3272
3273 def test_groups_parents(self):
3274 parent = ErrorRaisingArgumentParser(add_help=False)
3275 g = parent.add_argument_group(title='g', description='gd')
3276 g.add_argument('-w')
3277 g.add_argument('-x')
3278 m = parent.add_mutually_exclusive_group()
3279 m.add_argument('-y')
3280 m.add_argument('-z')
3281 parser = ErrorRaisingArgumentParser(prog='PROG', parents=[parent])
3282
3283 self.assertRaises(ArgumentParserError, parser.parse_args,
3284 ['-y', 'Y', '-z', 'Z'])
3285
3286 parser_help = parser.format_help()
3287 self.assertEqual(parser_help, textwrap.dedent('''\
3288 usage: PROG [-h] [-w W] [-x X] [-y Y | -z Z]
3289
3290 options:
3291 -h, --help show this help message and exit
3292 -y Y
3293 -z Z
3294
3295 g:
3296 gd
3297
3298 -w W
3299 -x X
3300 '''))
3301
3302 def test_wrong_type_parents(self):
3303 self.assertRaises(TypeError, ErrorRaisingArgumentParser, parents=[1])

Callers

nothing calls this directly

Calls 8

add_argument_groupMethod · 0.45
add_argumentMethod · 0.45
assertRaisesMethod · 0.45
format_helpMethod · 0.45
assertEqualMethod · 0.45
dedentMethod · 0.45

Tested by

no test coverage detected