(self)
| 2951 | help='%(prog)d') |
| 2952 | |
| 2953 | def test_subparser_title_help(self): |
| 2954 | parser = ErrorRaisingArgumentParser(prog='PROG', |
| 2955 | description='main description') |
| 2956 | parser.add_argument('--foo', action='store_true', help='foo help') |
| 2957 | parser.add_argument('bar', help='bar help') |
| 2958 | subparsers = parser.add_subparsers(title='subcommands', |
| 2959 | description='command help', |
| 2960 | help='additional text') |
| 2961 | parser1 = subparsers.add_parser('1') |
| 2962 | parser2 = subparsers.add_parser('2') |
| 2963 | self.assertEqual(parser.format_usage(), |
| 2964 | 'usage: PROG [-h] [--foo] bar {1,2} ...\n') |
| 2965 | self.assertEqual(parser.format_help(), textwrap.dedent('''\ |
| 2966 | usage: PROG [-h] [--foo] bar {1,2} ... |
| 2967 | |
| 2968 | main description |
| 2969 | |
| 2970 | positional arguments: |
| 2971 | bar bar help |
| 2972 | |
| 2973 | options: |
| 2974 | -h, --help show this help message and exit |
| 2975 | --foo foo help |
| 2976 | |
| 2977 | subcommands: |
| 2978 | command help |
| 2979 | |
| 2980 | {1,2} additional text |
| 2981 | ''')) |
| 2982 | |
| 2983 | def _test_subparser_help(self, args_str, expected_help): |
| 2984 | with self.assertRaises(ArgumentParserError) as cm: |
nothing calls this directly
no test coverage detected