@@ -628,9 +628,9 @@ class TestOptionalsNargsOptional(ParserTestCase):
628
628
Sig ('-w' , nargs = '?' ),
629
629
Sig ('-x' , nargs = '?' , const = 42 ),
630
630
Sig ('-y' , nargs = '?' , default = 'spam' ),
631
- Sig ('-z' , nargs = '?' , type = int , const = '42' , default = '84' ),
631
+ Sig ('-z' , nargs = '?' , type = int , const = '42' , default = '84' , choices = [ 1 , 2 ] ),
632
632
]
633
- failures = ['2' ]
633
+ failures = ['2' , '-z a' , '-z 42' , '-z 84' ]
634
634
successes = [
635
635
('' , NS (w = None , x = None , y = 'spam' , z = 84 )),
636
636
('-w' , NS (w = None , x = None , y = 'spam' , z = 84 )),
@@ -1027,8 +1027,8 @@ class TestPositionalsNargsZeroOrMore(ParserTestCase):
1027
1027
class TestPositionalsNargsZeroOrMoreDefault (ParserTestCase ):
1028
1028
"""Test a Positional that specifies unlimited nargs and a default"""
1029
1029
1030
- argument_signatures = [Sig ('foo' , nargs = '*' , default = 'bar' )]
1031
- failures = ['-x' ]
1030
+ argument_signatures = [Sig ('foo' , nargs = '*' , default = 'bar' , choices = [ 'a' , 'b' ] )]
1031
+ failures = ['-x' , 'bar' , 'a c' ]
1032
1032
successes = [
1033
1033
('' , NS (foo = 'bar' )),
1034
1034
('a' , NS (foo = ['a' ])),
@@ -1061,8 +1061,8 @@ class TestPositionalsNargsOptional(ParserTestCase):
1061
1061
class TestPositionalsNargsOptionalDefault (ParserTestCase ):
1062
1062
"""Tests an Optional Positional with a default value"""
1063
1063
1064
- argument_signatures = [Sig ('foo' , nargs = '?' , default = 42 )]
1065
- failures = ['-x' , 'a b' ]
1064
+ argument_signatures = [Sig ('foo' , nargs = '?' , default = 42 , choices = [ 'a' , 'b' ] )]
1065
+ failures = ['-x' , 'a b' , '42' ]
1066
1066
successes = [
1067
1067
('' , NS (foo = 42 )),
1068
1068
('a' , NS (foo = 'a' )),
@@ -1075,9 +1075,9 @@ class TestPositionalsNargsOptionalConvertedDefault(ParserTestCase):
1075
1075
"""
1076
1076
1077
1077
argument_signatures = [
1078
- Sig ('foo' , nargs = '?' , type = int , default = '42' ),
1078
+ Sig ('foo' , nargs = '?' , type = int , default = '42' , choices = [ 1 , 2 ] ),
1079
1079
]
1080
- failures = ['-x' , 'a b' , '1 2' ]
1080
+ failures = ['-x' , 'a b' , '1 2' , '42' ]
1081
1081
successes = [
1082
1082
('' , NS (foo = 42 )),
1083
1083
('1' , NS (foo = 1 )),
0 commit comments