@@ -628,9 +628,9 @@ class TestOptionalsNargsOptional(ParserTestCase):
628628 Sig ('-w' , nargs = '?' ),
629629 Sig ('-x' , nargs = '?' , const = 42 ),
630630 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 ] ),
632632 ]
633- failures = ['2' ]
633+ failures = ['2' , '-z a' , '-z 42' , '-z 84' ]
634634 successes = [
635635 ('' , NS (w = None , x = None , y = 'spam' , z = 84 )),
636636 ('-w' , NS (w = None , x = None , y = 'spam' , z = 84 )),
@@ -1027,8 +1027,8 @@ class TestPositionalsNargsZeroOrMore(ParserTestCase):
10271027class TestPositionalsNargsZeroOrMoreDefault (ParserTestCase ):
10281028 """Test a Positional that specifies unlimited nargs and a default"""
10291029
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' ]
10321032 successes = [
10331033 ('' , NS (foo = 'bar' )),
10341034 ('a' , NS (foo = ['a' ])),
@@ -1061,8 +1061,8 @@ class TestPositionalsNargsOptional(ParserTestCase):
10611061class TestPositionalsNargsOptionalDefault (ParserTestCase ):
10621062 """Tests an Optional Positional with a default value"""
10631063
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' ]
10661066 successes = [
10671067 ('' , NS (foo = 42 )),
10681068 ('a' , NS (foo = 'a' )),
@@ -1075,9 +1075,9 @@ class TestPositionalsNargsOptionalConvertedDefault(ParserTestCase):
10751075 """
10761076
10771077 argument_signatures = [
1078- Sig ('foo' , nargs = '?' , type = int , default = '42' ),
1078+ Sig ('foo' , nargs = '?' , type = int , default = '42' , choices = [ 1 , 2 ] ),
10791079 ]
1080- failures = ['-x' , 'a b' , '1 2' ]
1080+ failures = ['-x' , 'a b' , '1 2' , '42' ]
10811081 successes = [
10821082 ('' , NS (foo = 42 )),
10831083 ('1' , NS (foo = 1 )),
0 commit comments