@@ -1842,22 +1842,6 @@ def _get_parser(self, subparser_help=False, prefix_chars=None,
18421842 parser3 .add_argument ('t' , type = int , help = 't help' )
18431843 parser3 .add_argument ('u' , nargs = '...' , help = 'u help' )
18441844
1845- # add fourth sub-parser (to test abbreviations)
1846- parser4_kwargs = dict (description = 'lost description' )
1847- if subparser_help :
1848- parser4_kwargs ['help' ] = 'lost help'
1849- parser4 = subparsers .add_parser ('lost' , ** parser4_kwargs )
1850- parser4 .add_argument ('-w' , type = int , help = 'w help' )
1851- parser4 .add_argument ('x' , choices = 'abc' , help = 'x help' )
1852-
1853- # add fifth sub-parser, with longer name (to test abbreviations)
1854- parser5_kwargs = dict (description = 'long description' )
1855- if subparser_help :
1856- parser5_kwargs ['help' ] = 'long help'
1857- parser5 = subparsers .add_parser ('long' , ** parser5_kwargs )
1858- parser5 .add_argument ('-w' , type = int , help = 'w help' )
1859- parser5 .add_argument ('x' , choices = 'abc' , help = 'x help' )
1860-
18611845 # return the main parser
18621846 return parser
18631847
@@ -1873,24 +1857,6 @@ def test_parse_args_failures(self):
18731857 args = args_str .split ()
18741858 self .assertArgumentParserError (self .parser .parse_args , args )
18751859
1876- def test_parse_args_abbreviation (self ):
1877- # check some non-failure cases:
1878- self .assertEqual (
1879- self .parser .parse_args ('0.5 long b -w 7' .split ()),
1880- NS (foo = False , bar = 0.5 , w = 7 , x = 'b' ),
1881- )
1882- self .assertEqual (
1883- self .parser .parse_args ('0.5 lon b -w 7' .split ()),
1884- NS (foo = False , bar = 0.5 , w = 7 , x = 'b' ),
1885- )
1886- self .assertEqual (
1887- self .parser .parse_args ('0.5 los b -w 7' .split ()),
1888- NS (foo = False , bar = 0.5 , w = 7 , x = 'b' ),
1889- )
1890- # check a failure case: 'lo' is ambiguous
1891- self .assertArgumentParserError (self .parser .parse_args ,
1892- '0.5 lo b -w 7' .split ())
1893-
18941860 def test_parse_args (self ):
18951861 # check some non-failure cases:
18961862 self .assertEqual (
@@ -1943,80 +1909,78 @@ def test_dest(self):
19431909
19441910 def test_help (self ):
19451911 self .assertEqual (self .parser .format_usage (),
1946- 'usage: PROG [-h] [--foo] bar {1,2,3,lost,long } ...\n ' )
1912+ 'usage: PROG [-h] [--foo] bar {1,2,3} ...\n ' )
19471913 self .assertEqual (self .parser .format_help (), textwrap .dedent ('''\
1948- usage: PROG [-h] [--foo] bar {1,2,3,lost,long } ...
1914+ usage: PROG [-h] [--foo] bar {1,2,3} ...
19491915
19501916 main description
19511917
19521918 positional arguments:
1953- bar bar help
1954- {1,2,3,lost,long} command help
1919+ bar bar help
1920+ {1,2,3} command help
19551921
19561922 optional arguments:
1957- -h, --help show this help message and exit
1958- --foo foo help
1923+ -h, --help show this help message and exit
1924+ --foo foo help
19591925 ''' ))
19601926
19611927 def test_help_extra_prefix_chars (self ):
19621928 # Make sure - is still used for help if it is a non-first prefix char
19631929 parser = self ._get_parser (prefix_chars = '+:-' )
19641930 self .assertEqual (parser .format_usage (),
1965- 'usage: PROG [-h] [++foo] bar {1,2,3,lost,long } ...\n ' )
1931+ 'usage: PROG [-h] [++foo] bar {1,2,3} ...\n ' )
19661932 self .assertEqual (parser .format_help (), textwrap .dedent ('''\
1967- usage: PROG [-h] [++foo] bar {1,2,3,lost,long } ...
1933+ usage: PROG [-h] [++foo] bar {1,2,3} ...
19681934
19691935 main description
19701936
19711937 positional arguments:
1972- bar bar help
1973- {1,2,3,lost,long} command help
1938+ bar bar help
1939+ {1,2,3} command help
19741940
19751941 optional arguments:
1976- -h, --help show this help message and exit
1977- ++foo foo help
1942+ -h, --help show this help message and exit
1943+ ++foo foo help
19781944 ''' ))
19791945
19801946
19811947 def test_help_alternate_prefix_chars (self ):
19821948 parser = self ._get_parser (prefix_chars = '+:/' )
19831949 self .assertEqual (parser .format_usage (),
1984- 'usage: PROG [+h] [++foo] bar {1,2,3,lost,long } ...\n ' )
1950+ 'usage: PROG [+h] [++foo] bar {1,2,3} ...\n ' )
19851951 self .assertEqual (parser .format_help (), textwrap .dedent ('''\
1986- usage: PROG [+h] [++foo] bar {1,2,3,lost,long } ...
1952+ usage: PROG [+h] [++foo] bar {1,2,3} ...
19871953
19881954 main description
19891955
19901956 positional arguments:
1991- bar bar help
1992- {1,2,3,lost,long} command help
1957+ bar bar help
1958+ {1,2,3} command help
19931959
19941960 optional arguments:
1995- +h, ++help show this help message and exit
1996- ++foo foo help
1961+ +h, ++help show this help message and exit
1962+ ++foo foo help
19971963 ''' ))
19981964
19991965 def test_parser_command_help (self ):
20001966 self .assertEqual (self .command_help_parser .format_usage (),
2001- 'usage: PROG [-h] [--foo] bar {1,2,3,lost,long } ...\n ' )
1967+ 'usage: PROG [-h] [--foo] bar {1,2,3} ...\n ' )
20021968 self .assertEqual (self .command_help_parser .format_help (),
20031969 textwrap .dedent ('''\
2004- usage: PROG [-h] [--foo] bar {1,2,3,lost,long } ...
1970+ usage: PROG [-h] [--foo] bar {1,2,3} ...
20051971
20061972 main description
20071973
20081974 positional arguments:
2009- bar bar help
2010- {1,2,3,lost,long} command help
2011- 1 1 help
2012- 2 2 help
2013- 3 3 help
2014- lost lost help
2015- long long help
1975+ bar bar help
1976+ {1,2,3} command help
1977+ 1 1 help
1978+ 2 2 help
1979+ 3 3 help
20161980
20171981 optional arguments:
2018- -h, --help show this help message and exit
2019- --foo foo help
1982+ -h, --help show this help message and exit
1983+ --foo foo help
20201984 ''' ))
20211985
20221986 def test_subparser_title_help (self ):
@@ -2119,8 +2083,6 @@ def test_alias_help(self):
21192083 1 help
21202084 2 2 help
21212085 3 3 help
2122- lost lost help
2123- long long help
21242086 """ ))
21252087
21262088# ============
0 commit comments