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

Method test_mutex_groups_parents

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

Source from the content-addressed store, hash-verified

3303 self.assertRaises(TypeError, ErrorRaisingArgumentParser, parents=[1])
3304
3305 def test_mutex_groups_parents(self):
3306 parent = ErrorRaisingArgumentParser(add_help=False)
3307 g = parent.add_argument_group(title='g', description='gd')
3308 g.add_argument('-w')
3309 g.add_argument('-x')
3310 m = g.add_mutually_exclusive_group()
3311 m.add_argument('-y')
3312 m.add_argument('-z')
3313 parser = ErrorRaisingArgumentParser(prog='PROG', parents=[parent])
3314
3315 self.assertRaises(ArgumentParserError, parser.parse_args,
3316 ['-y', 'Y', '-z', 'Z'])
3317
3318 parser_help = parser.format_help()
3319 self.assertEqual(parser_help, textwrap.dedent('''\
3320 usage: PROG [-h] [-w W] [-x X] [-y Y | -z Z]
3321
3322 options:
3323 -h, --help show this help message and exit
3324
3325 g:
3326 gd
3327
3328 -w W
3329 -x X
3330 -y Y
3331 -z Z
3332 '''))
3333
3334# ==============================
3335# Mutually exclusive group tests

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