Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ee91e09

Browse files
committed
#11906 Make test_argparse work interactively by removing extra space
in comparison string that argparse does not add when program name is blank.
1 parent ac8bfca commit ee91e09

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

Lib/test/test_argparse.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2170,8 +2170,9 @@ def test_parent_help(self):
21702170
parents = [self.abcd_parent, self.wxyz_parent]
21712171
parser = ErrorRaisingArgumentParser(parents=parents)
21722172
parser_help = parser.format_help()
2173+
progname = self.main_program
21732174
self.assertEqual(parser_help, textwrap.dedent('''\
2174-
usage: {} [-h] [-b B] [--d D] [--w W] [-y Y] a z
2175+
usage: {}{}[-h] [-b B] [--d D] [--w W] [-y Y] a z
21752176
21762177
positional arguments:
21772178
a
@@ -2187,7 +2188,7 @@ def test_parent_help(self):
21872188
21882189
x:
21892190
-y Y
2190-
'''.format(self.main_program)))
2191+
'''.format(progname, ' ' if progname else '' )))
21912192

21922193
def test_groups_parents(self):
21932194
parent = ErrorRaisingArgumentParser(add_help=False)
@@ -2203,8 +2204,9 @@ def test_groups_parents(self):
22032204
['-y', 'Y', '-z', 'Z'])
22042205

22052206
parser_help = parser.format_help()
2207+
progname = self.main_program
22062208
self.assertEqual(parser_help, textwrap.dedent('''\
2207-
usage: {} [-h] [-w W] [-x X] [-y Y | -z Z]
2209+
usage: {}{}[-h] [-w W] [-x X] [-y Y | -z Z]
22082210
22092211
optional arguments:
22102212
-h, --help show this help message and exit
@@ -2216,7 +2218,7 @@ def test_groups_parents(self):
22162218
22172219
-w W
22182220
-x X
2219-
'''.format(self.main_program)))
2221+
'''.format(progname, ' ' if progname else '' )))
22202222

22212223
# ==============================
22222224
# Mutually exclusive group tests

0 commit comments

Comments
 (0)