Mercurial > cpython-lru_cache-weakref
diff Lib/test/test_argparse.py @ 65869:d8ab35ec486e
Fix for issue 9355 where with multiple mutually exclusive arguments, some brackets were being lost in the usage messages
| author | Steven Bethard <steven.bethard@gmail.com> |
|---|---|
| date | Mon, 01 Nov 2010 16:29:26 +0000 |
| parents | cb9e10034e4a |
| children | ff6f39b3c38e |
line wrap: on
line diff
--- a/Lib/test/test_argparse.py Mon Nov 01 15:57:36 2010 +0000 +++ b/Lib/test/test_argparse.py Mon Nov 01 16:29:26 2010 +0000 @@ -2163,6 +2163,25 @@ raises(ValueError, add_argument, 'bar', nargs=1) raises(ValueError, add_argument, 'bar', nargs=argparse.PARSER) + def test_help(self): + parser = ErrorRaisingArgumentParser(prog='PROG') + group1 = parser.add_mutually_exclusive_group() + group1.add_argument('--foo', action='store_true') + group1.add_argument('--bar', action='store_false') + group2 = parser.add_mutually_exclusive_group() + group2.add_argument('--soup', action='store_true') + group2.add_argument('--nuts', action='store_false') + expected = '''\ + usage: PROG [-h] [--foo | --bar] [--soup | --nuts] + + optional arguments: + -h, --help show this help message and exit + --foo + --bar + --soup + --nuts + ''' + self.assertEqual(parser.format_help(), textwrap.dedent(expected)) class MEMixin(object):
