Home | History | Annotate | Download | only in test

Lines Matching refs:nargs

550     argument_signatures = [Sig('-x', nargs=1)]
561 argument_signatures = [Sig('-x', nargs=3)]
573 Sig('-w', nargs='?'),
574 Sig('-x', nargs='?', const=42),
575 Sig('-y', nargs='?', default='spam'),
576 Sig('-z', nargs='?', type=int, const='42', default='84'),
596 Sig('-x', nargs='*'),
597 Sig('-y', nargs='*', default='spam'),
615 Sig('-x', nargs='+'),
616 Sig('-y', nargs='+', default='spam'),
772 """Test a Positional that doesn't specify nargs"""
782 """Test a Positional that specifies an nargs of 1"""
784 argument_signatures = [Sig('foo', nargs=1)]
792 """Test a Positional that specifies an nargs of 2"""
794 argument_signatures = [Sig('foo', nargs=2)]
802 """Test a Positional that specifies unlimited nargs"""
804 argument_signatures = [Sig('foo', nargs='*')]
814 """Test a Positional that specifies unlimited nargs and a default"""
816 argument_signatures = [Sig('foo', nargs='*', default='bar')]
826 """Test a Positional that specifies one or more nargs"""
828 argument_signatures = [Sig('foo', nargs='+')]
839 argument_signatures = [Sig('foo', nargs='?')]
850 argument_signatures = [Sig('foo', nargs='?', default=42)]
864 Sig('foo', nargs='?', type=int, default='42'),
874 """Test two Positionals that don't specify nargs"""
884 """Test a Positional with no nargs followed by one with 1"""
886 argument_signatures = [Sig('foo'), Sig('bar', nargs=1)]
894 """Test a Positional with 2 nargs followed by one with none"""
896 argument_signatures = [Sig('foo', nargs=2), Sig('bar')]
904 """Test a Positional with no nargs followed by one with unlimited"""
906 argument_signatures = [Sig('foo'), Sig('bar', nargs='*')]
916 """Test a Positional with no nargs followed by one with one or more"""
918 argument_signatures = [Sig('foo'), Sig('bar', nargs='+')]
927 """Test a Positional with no nargs followed by one with an Optional"""
929 argument_signatures = [Sig('foo'), Sig('bar', nargs='?')]
938 """Test a Positional with unlimited nargs followed by one with none"""
940 argument_signatures = [Sig('foo', nargs='*'), Sig('bar')]
950 """Test a Positional with one or more nargs followed by one with none"""
952 argument_signatures = [Sig('foo', nargs='+'), Sig('bar')]
961 """Test a Positional with an Optional nargs followed by one with none"""
963 argument_signatures = [Sig('foo', nargs='?', default=42), Sig('bar')]
972 """Test a Positional with 2 nargs followed by one with unlimited"""
974 argument_signatures = [Sig('foo', nargs=2), Sig('bar', nargs='*')]
983 """Test a Positional with 2 nargs followed by one with one or more"""
985 argument_signatures = [Sig('foo', nargs=2), Sig('bar', nargs='+')]
993 """Test a Positional with 2 nargs followed by one optional"""
995 argument_signatures = [Sig('foo', nargs=2), Sig('bar', nargs='?')]
1004 """Test a Positional with unlimited nargs followed by one with 1"""
1006 argument_signatures = [Sig('foo', nargs='*'), Sig('bar', nargs=1)]
1016 """Test a Positional with one or more nargs followed by one with 1"""
1018 argument_signatures = [Sig('foo', nargs='+'), Sig('bar', nargs=1)]
1027 """Test a Positional with an Optional nargs followed by one with 1"""
1029 argument_signatures = [Sig('foo', nargs='?'), Sig('bar', nargs=1)]
1038 """Test three Positionals: no nargs, unlimited nargs and 1 nargs"""
1042 Sig('bar', nargs='*'),
1043 Sig('baz', nargs=1),
1053 """Test three Positionals: no nargs, one or more nargs and 1 nargs"""
1057 Sig('bar', nargs='+'),
1058 Sig('baz', nargs=1),
1068 """Test three Positionals: no nargs, optional narg and 1 nargs"""
1072 Sig('bar', nargs='?', default=0.625),
1073 Sig('baz', nargs=1),
1083 """Test two optional nargs"""
1086 Sig('foo', nargs='?'),
1087 Sig('bar', nargs='?', default=42),
1098 """Test an Optional narg followed by unlimited nargs"""
1100 argument_signatures = [Sig('foo', nargs='?'), Sig('bar', nargs='*')]
1111 """Test an Optional narg followed by one or more nargs"""
1113 argument_signatures = [Sig('foo', nargs='?'), Sig('bar', nargs='+')]
1149 Sig('spam', action='append', nargs=2),
1164 Sig('x', nargs='?'),
1180 Sig('x', nargs='?'),
1196 Sig('x', nargs='?'),
1216 Sig('-', dest='x', nargs='?', const='badger'),
1234 argument_signatures = [Sig('-x', nargs='*'), Sig('y', nargs='*')]
1248 """Tests specifying a positional with nargs=REMAINDER"""
1250 argument_signatures = [Sig('x'), Sig('y', nargs='...'), Sig('-z')]
1266 Sig('z', nargs='*'),
1291 Sig('foo', nargs='?', default=argparse.SUPPRESS),
1292 Sig('bar', nargs='*', default=argparse.SUPPRESS),
1311 Sig('foo', nargs='?'),
1312 Sig('bar', nargs='*'),
1331 Sig('foo', nargs='?'),
1332 Sig('bar', nargs='*'),
1367 Sig('y', nargs='+'),
1404 Sig('y', nargs='+'),
1709 type=int, nargs='?', default=2),
1781 parser2.add_argument('z', type=complex, nargs='*', help='z help')
1789 parser3.add_argument('u', nargs='...', help='u help')
2236 raises(ValueError, add_argument, 'bar', nargs='+')
2237 raises(ValueError, add_argument, 'bar', nargs=1)
2238 raises(ValueError, add_argument, 'bar', nargs=argparse.PARSER)
2314 group.add_argument('--baz', nargs='?', const='Z', help='baz help')
2462 group.add_argument('badger', nargs='*', default='X', help='BADGER')
2589 group.add_argument('a', nargs='?', help='a help')
2731 parser.add_argument('y', nargs='?')
2732 parser.add_argument('z', nargs='?', default='ZZ')
2749 group.add_argument('y', nargs='?')
2750 group.add_argument('z', nargs='?', default='ZZ')
2954 Sig('-z', nargs='+', help='Z HELP')]),
3168 Sig('-w', nargs='+', help='w'),
3169 Sig('-x', nargs='*', help='x'),
3171 Sig('b', help='b', nargs=2),
3172 Sig('c', help='c', nargs='?'),
3176 Sig('-y', nargs='?', help='y'),
3177 Sig('-z', nargs=3, help='z'),
3178 Sig('d', help='d', nargs='*'),
3179 Sig('e', help='e', nargs='+'),
3770 Sig('-w', help='w', nargs='+', metavar=('W1', 'W2')),
3771 Sig('-x', help='x', nargs='*', metavar=('X1', 'X2')),
3772 Sig('-y', help='y', nargs=3, metavar=('Y1', 'Y2', 'Y3')),
3773 Sig('-z', help='z', nargs='?', metavar=('Z1', )),
3900 Sig('badger', nargs='?', default='wooden', help='badger help'),
4082 for attrs in [dict(type=int), dict(nargs='+'),
4093 # nargs is always disallowed
4094 self.assertTypeError('-x', nargs='*', action=action)
4099 # nargs=0 is disallowed
4100 self.assertValueError('-x', nargs=0, action=action)
4101 self.assertValueError('spam', nargs=0, action=action)
4104 for nargs in [1, '*', '+']:
4106 nargs=nargs, action=action)
4108 nargs=nargs, action=action)
4113 # nargs is always disallowed
4114 self.assertTypeError('-x', nargs='+', action=action)
4169 action = parser.add_argument('--foo', nargs='?', const=42,
4172 self.assertEqual(action.nargs, '?')
4329 nargs='+',
4336 "nargs='+', const=None, default=42, type='int', "
4345 nargs='?',
4351 "Action(option_strings=[], dest='x', nargs='?', "
4549 parser.add_argument('-v', nargs='?', const=1, type=int)
4564 EXPECTED_MESSAGE = "length of metavar tuple does not match nargs"
4566 def do_test_no_exception(self, nargs, metavar):
4568 parser.add_argument("--foo", nargs=nargs, metavar=metavar)
4570 def do_test_exception(self, nargs, metavar):
4573 parser.add_argument("--foo", nargs=nargs, metavar=metavar)
4576 # Unit tests for different values of metavar when nargs=None
4579 self.do_test_no_exception(nargs=None, metavar="1")
4582 self.do_test_exception(nargs=None, metavar=tuple())
4585 self.do_test_no_exception(nargs=None, metavar=("1"))
4588 self.do_test_exception(nargs=None, metavar=("1", "2"))
4591 self.do_test_exception(nargs=None, metavar=("1", "2", "3"))
4593 # Unit tests for different values of metavar when nargs=?
4596 self.do_test_no_exception(nargs="?", metavar="1")
4599 self.do_test_exception(nargs="?", metavar=tuple())
4602 self.do_test_no_exception(nargs="?", metavar=("1"))
4605 self.do_test_exception(nargs="?", metavar=("1", "2"))
4608 self.do_test_exception(nargs="?", metavar=("1", "2", "3"))
4610 # Unit tests for different values of metavar when nargs=*
4613 self.do_test_no_exception(nargs="*", metavar="1")
4616 self.do_test_exception(nargs="*", metavar=tuple())
4619 self.do_test_no_exception(nargs="*", metavar=("1"))
4622 self.do_test_no_exception(nargs="*", metavar=("1", "2"))
4625 self.do_test_exception(nargs="*", metavar=("1", "2", "3"))
4627 # Unit tests for different values of metavar when nargs=+
4630 self.do_test_no_exception(nargs="+", metavar="1")
4633 self.do_test_exception(nargs="+", metavar=tuple())
4636 self.do_test_no_exception(nargs="+", metavar=("1"))
4639 self.do_test_no_exception(nargs="+", metavar=("1", "2"))
4642 self.do_test_exception(nargs="+", metavar=("1", "2", "3"))
4644 # Unit tests for different values of metavar when nargs=...
4647 self.do_test_no_exception(nargs="...", metavar="1")
4650 self.do_test_no_exception(nargs="...", metavar=tuple())
4653 self.do_test_no_exception(nargs="...", metavar=("1"))
4656 self.do_test_no_exception(nargs="...", metavar=("1", "2"))
4659 self.do_test_no_exception(nargs="...", metavar=("1", "2", "3"))
4661 # Unit tests for different values of metavar when nargs=A...
4664 self.do_test_no_exception(nargs="A...", metavar="1")
4667 self.do_test_exception(nargs="A...", metavar=tuple())
4670 self.do_test_no_exception(nargs="A...", metavar=("1"))
4673 self.do_test_exception(nargs="A...", metavar=("1", "2"))
4676 self.do_test_exception(nargs="A...", metavar=("1", "2", "3"))
4678 # Unit tests for different values of metavar when nargs=1
4681 self.do_test_no_exception(nargs=1, metavar="1")
4684 self.do_test_exception(nargs=1, metavar=tuple())
4687 self.do_test_no_exception(nargs=1, metavar=("1"))
4690 self.do_test_exception(nargs=1, metavar=("1", "2"))
4693 self.do_test_exception(nargs=1, metavar=("1", "2", "3"))
4695 # Unit tests for different values of metavar when nargs=2
4698 self.do_test_no_exception(nargs=2, metavar="1")
4701 self.do_test_exception(nargs=2, metavar=tuple())
4704 self.do_test_no_exception(nargs=2, metavar=("1"))
4707 self.do_test_no_exception(nargs=2, metavar=("1", "2"))
4710 self.do_test_exception(nargs=2, metavar=("1", "2", "3"))
4712 # Unit tests for different values of metavar when nargs=3
4715 self.do_test_no_exception(nargs=3, metavar="1")
4718 self.do_test_exception(nargs=3, metavar=tuple())
4721 self.do_test_no_exception(nargs=3, metavar=("1"))
4724 self.do_test_exception(nargs=3, metavar=("1", "2"))
4727 self.do_test_no_exception(nargs=3, metavar=("1", "2", "3"))