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.
diff --git a/Lib/test/test_optparse.py b/Lib/test/test_optparse.py
index d4e5bb9..44927d6 100644
--- a/Lib/test/test_optparse.py
+++ b/Lib/test/test_optparse.py
@@ -1444,6 +1444,39 @@
-h, --help show this help message and exit
"""
+_expected_very_help_short_lines = """\
+Usage: bar.py [options]
+
+Options:
+ -a APPLE
+ throw
+ APPLEs at
+ basket
+ -b NUM, --boo=NUM
+ shout
+ "boo!" NUM
+ times (in
+ order to
+ frighten
+ away all
+ the evil
+ spirits
+ that cause
+ trouble and
+ mayhem)
+ --foo=FOO
+ store FOO
+ in the foo
+ list for
+ later
+ fooing
+ -h, --help
+ show this
+ help
+ message and
+ exit
+"""
+
class TestHelp(BaseTest):
def setUp(self):
self.parser = self.make_parser(80)
@@ -1505,6 +1538,8 @@
# we look at $COLUMNS.
self.parser = self.make_parser(60)
self.assertHelpEquals(_expected_help_short_lines)
+ self.parser = self.make_parser(0)
+ self.assertHelpEquals(_expected_very_help_short_lines)
def test_help_unicode(self):
self.parser = InterceptingOptionParser(usage=SUPPRESS_USAGE)