@@ -621,9 +621,9 @@ class TestOptionalsNargsOptional(ParserTestCase):
621621 Sig ('-w' , nargs = '?' ),
622622 Sig ('-x' , nargs = '?' , const = 42 ),
623623 Sig ('-y' , nargs = '?' , default = 'spam' ),
624- Sig ('-z' , nargs = '?' , type = int , const = '42' , default = '84' ),
624+ Sig ('-z' , nargs = '?' , type = int , const = '42' , default = '84' , choices = [ 1 , 2 ] ),
625625 ]
626- failures = ['2' ]
626+ failures = ['2' , '-z a' , '-z 42' , '-z 84' ]
627627 successes = [
628628 ('' , NS (w = None , x = None , y = 'spam' , z = 84 )),
629629 ('-w' , NS (w = None , x = None , y = 'spam' , z = 84 )),
@@ -1001,8 +1001,8 @@ class TestPositionalsNargsZeroOrMore(ParserTestCase):
10011001class TestPositionalsNargsZeroOrMoreDefault (ParserTestCase ):
10021002 """Test a Positional that specifies unlimited nargs and a default"""
10031003
1004- argument_signatures = [Sig ('foo' , nargs = '*' , default = 'bar' )]
1005- failures = ['-x' ]
1004+ argument_signatures = [Sig ('foo' , nargs = '*' , default = 'bar' , choices = [ 'a' , 'b' ] )]
1005+ failures = ['-x' , 'bar' , 'a c' ]
10061006 successes = [
10071007 ('' , NS (foo = 'bar' )),
10081008 ('a' , NS (foo = ['a' ])),
@@ -1035,8 +1035,8 @@ class TestPositionalsNargsOptional(ParserTestCase):
10351035class TestPositionalsNargsOptionalDefault (ParserTestCase ):
10361036 """Tests an Optional Positional with a default value"""
10371037
1038- argument_signatures = [Sig ('foo' , nargs = '?' , default = 42 )]
1039- failures = ['-x' , 'a b' ]
1038+ argument_signatures = [Sig ('foo' , nargs = '?' , default = 42 , choices = [ 'a' , 'b' ] )]
1039+ failures = ['-x' , 'a b' , '42' ]
10401040 successes = [
10411041 ('' , NS (foo = 42 )),
10421042 ('a' , NS (foo = 'a' )),
@@ -1049,9 +1049,9 @@ class TestPositionalsNargsOptionalConvertedDefault(ParserTestCase):
10491049 """
10501050
10511051 argument_signatures = [
1052- Sig ('foo' , nargs = '?' , type = int , default = '42' ),
1052+ Sig ('foo' , nargs = '?' , type = int , default = '42' , choices = [ 1 , 2 ] ),
10531053 ]
1054- failures = ['-x' , 'a b' , '1 2' ]
1054+ failures = ['-x' , 'a b' , '1 2' , '42' ]
10551055 successes = [
10561056 ('' , NS (foo = 42 )),
10571057 ('1' , NS (foo = 1 )),
0 commit comments