mirror of
https://github.com/python/cpython.git
synced 2025-08-27 12:16:04 +00:00
Issue #13107: argparse and optparse no longer raises an exception when output
a help on environment with too small COLUMNS. Based on patch by Elazar Gershuni.
This commit is contained in:
parent
32c4915b23
commit
f451112413
6 changed files with 103 additions and 6 deletions
|
@ -2973,6 +2973,60 @@ class TestHelpBiggerOptionals(HelpTestCase):
|
|||
0.1
|
||||
'''
|
||||
|
||||
class TestShortColumns(HelpTestCase):
|
||||
'''Test extremely small number of columns.
|
||||
|
||||
TestCase prevents "COLUMNS" from being too small in the tests themselves,
|
||||
but we don't want any exceptions thrown in such case. Only ugly representation.
|
||||
'''
|
||||
def setUp(self):
|
||||
env = support.EnvironmentVarGuard()
|
||||
env.set("COLUMNS", '15')
|
||||
self.addCleanup(env.__exit__)
|
||||
|
||||
parser_signature = TestHelpBiggerOptionals.parser_signature
|
||||
argument_signatures = TestHelpBiggerOptionals.argument_signatures
|
||||
argument_group_signatures = TestHelpBiggerOptionals.argument_group_signatures
|
||||
usage = '''\
|
||||
usage: PROG
|
||||
[-h]
|
||||
[-v]
|
||||
[-x]
|
||||
[--y Y]
|
||||
foo
|
||||
bar
|
||||
'''
|
||||
help = usage + '''\
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
positional arguments:
|
||||
foo
|
||||
FOO HELP
|
||||
bar
|
||||
BAR HELP
|
||||
|
||||
optional arguments:
|
||||
-h, --help
|
||||
show this
|
||||
help
|
||||
message and
|
||||
exit
|
||||
-v, --version
|
||||
show
|
||||
program's
|
||||
version
|
||||
number and
|
||||
exit
|
||||
-x
|
||||
X HELP
|
||||
--y Y
|
||||
Y HELP
|
||||
|
||||
EPILOG
|
||||
'''
|
||||
version = TestHelpBiggerOptionals.version
|
||||
|
||||
|
||||
class TestHelpBiggerOptionalGroups(HelpTestCase):
|
||||
"""Make sure that argument help aligns when options are longer"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue