mirror of
https://github.com/python/cpython.git
synced 2025-08-09 19:38:42 +00:00
Merged revisions 86111 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r86111 | steven.bethard | 2010-11-02 13:47:22 +0100 (Tue, 02 Nov 2010) | 1 line Fix bug 9340 - argparse parse_known_args didn't work with subparsers ........
This commit is contained in:
parent
a54bf8b006
commit
2e4d4c414e
2 changed files with 34 additions and 2 deletions
|
@ -1784,6 +1784,28 @@ class TestAddSubparsers(TestCase):
|
|||
NS(foo=True, bar=0.125, w=None, x='c'),
|
||||
)
|
||||
|
||||
def test_parse_known_args(self):
|
||||
self.assertEqual(
|
||||
self.parser.parse_known_args('0.5 1 b -w 7'.split()),
|
||||
(NS(foo=False, bar=0.5, w=7, x='b'), []),
|
||||
)
|
||||
self.assertEqual(
|
||||
self.parser.parse_known_args('0.5 -p 1 b -w 7'.split()),
|
||||
(NS(foo=False, bar=0.5, w=7, x='b'), ['-p']),
|
||||
)
|
||||
self.assertEqual(
|
||||
self.parser.parse_known_args('0.5 1 b -w 7 -p'.split()),
|
||||
(NS(foo=False, bar=0.5, w=7, x='b'), ['-p']),
|
||||
)
|
||||
self.assertEqual(
|
||||
self.parser.parse_known_args('0.5 1 b -q -rs -w 7'.split()),
|
||||
(NS(foo=False, bar=0.5, w=7, x='b'), ['-q', '-rs']),
|
||||
)
|
||||
self.assertEqual(
|
||||
self.parser.parse_known_args('0.5 -W 1 b -X Y -w 7 Z'.split()),
|
||||
(NS(foo=False, bar=0.5, w=7, x='b'), ['-W', '-X', 'Y', 'Z']),
|
||||
)
|
||||
|
||||
def test_dest(self):
|
||||
parser = ErrorRaisingArgumentParser()
|
||||
parser.add_argument('--foo', action='store_true')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue