diff options
author | Steven Bethard <steven.bethard@gmail.com> | 2010-11-02 12:47:22 (GMT) |
---|---|---|
committer | Steven Bethard <steven.bethard@gmail.com> | 2010-11-02 12:47:22 (GMT) |
commit | fca2e8aeb8e841a18c4b9d2954254b2a086a3d56 (patch) | |
tree | 5139e39cd686fabb98dad2407c7df3b4a6d1c406 /Lib/test/test_argparse.py | |
parent | b68928bea70b0d9f33e0dc0a9c950291f8c65f15 (diff) | |
download | cpython-fca2e8aeb8e841a18c4b9d2954254b2a086a3d56.zip cpython-fca2e8aeb8e841a18c4b9d2954254b2a086a3d56.tar.gz cpython-fca2e8aeb8e841a18c4b9d2954254b2a086a3d56.tar.bz2 |
Fix bug 9340 - argparse parse_known_args didn't work with subparsers
Diffstat (limited to 'Lib/test/test_argparse.py')
-rw-r--r-- | Lib/test/test_argparse.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py index 1503ccd..74075bb 100644 --- a/Lib/test/test_argparse.py +++ b/Lib/test/test_argparse.py @@ -1773,6 +1773,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') |