@@ -1773,6 +1773,28 @@ def test_parse_args(self):
17731773 NS (foo = True , bar = 0.125 , w = None , x = 'c' ),
17741774 )
17751775
1776+ def test_parse_known_args (self ):
1777+ self .assertEqual (
1778+ self .parser .parse_known_args ('0.5 1 b -w 7' .split ()),
1779+ (NS (foo = False , bar = 0.5 , w = 7 , x = 'b' ), []),
1780+ )
1781+ self .assertEqual (
1782+ self .parser .parse_known_args ('0.5 -p 1 b -w 7' .split ()),
1783+ (NS (foo = False , bar = 0.5 , w = 7 , x = 'b' ), ['-p' ]),
1784+ )
1785+ self .assertEqual (
1786+ self .parser .parse_known_args ('0.5 1 b -w 7 -p' .split ()),
1787+ (NS (foo = False , bar = 0.5 , w = 7 , x = 'b' ), ['-p' ]),
1788+ )
1789+ self .assertEqual (
1790+ self .parser .parse_known_args ('0.5 1 b -q -rs -w 7' .split ()),
1791+ (NS (foo = False , bar = 0.5 , w = 7 , x = 'b' ), ['-q' , '-rs' ]),
1792+ )
1793+ self .assertEqual (
1794+ self .parser .parse_known_args ('0.5 -W 1 b -X Y -w 7 Z' .split ()),
1795+ (NS (foo = False , bar = 0.5 , w = 7 , x = 'b' ), ['-W' , '-X' , 'Y' , 'Z' ]),
1796+ )
1797+
17761798 def test_dest (self ):
17771799 parser = ErrorRaisingArgumentParser ()
17781800 parser .add_argument ('--foo' , action = 'store_true' )
0 commit comments