summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorsteven.bethard <devnull@localhost>2009-09-12 23:35:45 +0000
committersteven.bethard <devnull@localhost>2009-09-12 23:35:45 +0000
commita3fd557914767c2faa52fea2297beb5b88cb7a73 (patch)
treec0a23eec8148c2f4dd4eb2f675818281ac29f301 /test
parentff7fc5019350fdddede1961aab7a6892e0cd01c2 (diff)
downloadargparse-a3fd557914767c2faa52fea2297beb5b88cb7a73.tar.gz
Fix bug with long prog= values.
Diffstat (limited to 'test')
-rw-r--r--test/test_argparse.py98
1 files changed, 94 insertions, 4 deletions
diff --git a/test/test_argparse.py b/test/test_argparse.py
index 57de0c4..447a4dd 100644
--- a/test/test_argparse.py
+++ b/test/test_argparse.py
@@ -2095,12 +2095,12 @@ class TestMutuallyExclusiveLong(MEMixin, TestCase):
]
usage_when_not_required = '''\
- usage: PROG [-h] [--abcde ABCDE] [--fghij FGHIJ] [--klmno KLMNO | --pqrst
- PQRST]
+ usage: PROG [-h] [--abcde ABCDE] [--fghij FGHIJ]
+ [--klmno KLMNO | --pqrst PQRST]
'''
usage_when_required = '''\
- usage: PROG [-h] [--abcde ABCDE] [--fghij FGHIJ] (--klmno KLMNO | --pqrst
- PQRST)
+ usage: PROG [-h] [--abcde ABCDE] [--fghij FGHIJ]
+ (--klmno KLMNO | --pqrst PQRST)
'''
help = '''\
@@ -2855,6 +2855,96 @@ class TestHelpOnlyUserGroups(HelpTestCase):
version = ''
+class TestHelpUsageLongProg(HelpTestCase):
+ """Test usage messages where the prog is long"""
+
+ parser_signature = Sig(prog='P' * 60)
+ argument_signatures = [
+ Sig('-w', metavar='W'),
+ Sig('-x', metavar='X'),
+ Sig('a'),
+ Sig('b'),
+ ]
+ argument_group_signatures = []
+ usage = '''\
+ usage: PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
+ [-h] [-w W] [-x X] a b
+ '''
+ help = usage + '''\
+
+ positional arguments:
+ a
+ b
+
+ optional arguments:
+ -h, --help show this help message and exit
+ -w W
+ -x X
+ '''
+ version = ''
+
+
+class TestHelpUsageLongProgOptionsWrap(HelpTestCase):
+ """Test usage messages where the prog is long and the optionals wrap"""
+
+ parser_signature = Sig(prog='P' * 60)
+ argument_signatures = [
+ Sig('-w', metavar='W' * 25),
+ Sig('-x', metavar='X' * 25),
+ Sig('-y', metavar='Y' * 25),
+ Sig('-z', metavar='Z' * 25),
+ Sig('a'),
+ Sig('b'),
+ ]
+ argument_group_signatures = []
+ usage = '''\
+ usage: PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
+ [-h] [-w WWWWWWWWWWWWWWWWWWWWWWWWW] \
+[-x XXXXXXXXXXXXXXXXXXXXXXXXX]
+ [-y YYYYYYYYYYYYYYYYYYYYYYYYY] [-z ZZZZZZZZZZZZZZZZZZZZZZZZZ]
+ a b
+ '''
+ help = usage + '''\
+
+ positional arguments:
+ a
+ b
+
+ optional arguments:
+ -h, --help show this help message and exit
+ -w WWWWWWWWWWWWWWWWWWWWWWWWW
+ -x XXXXXXXXXXXXXXXXXXXXXXXXX
+ -y YYYYYYYYYYYYYYYYYYYYYYYYY
+ -z ZZZZZZZZZZZZZZZZZZZZZZZZZ
+ '''
+ version = ''
+
+
+class TestHelpUsageLongProgPositionalsWrap(HelpTestCase):
+ """Test usage messages where the prog is long and the positionals wrap"""
+
+ parser_signature = Sig(prog='P' * 60, add_help=False)
+ argument_signatures = [
+ Sig('a' * 25),
+ Sig('b' * 25),
+ Sig('c' * 25),
+ ]
+ argument_group_signatures = []
+ usage = '''\
+ usage: PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
+ aaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbb
+ ccccccccccccccccccccccccc
+ '''
+ help = usage + '''\
+
+ positional arguments:
+ aaaaaaaaaaaaaaaaaaaaaaaaa
+ bbbbbbbbbbbbbbbbbbbbbbbbb
+ ccccccccccccccccccccccccc
+ '''
+ version = ''
+
+
class TestHelpUsageOptionalsWrap(HelpTestCase):
"""Test usage messages where the optionals wrap"""