gh-92445 Improve interaction between nargs="*" and choices() (GH-92565)

This commit is contained in:
Harry 2022-08-25 12:18:38 +01:00 committed by GitHub
parent cd492d43a2
commit ad7340e8c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

View file

@ -5230,6 +5230,13 @@ class TestParseKnownArgs(TestCase):
self.assertEqual(NS(v=3, spam=True, badger="B"), args)
self.assertEqual(["C", "--foo", "4"], extras)
def test_zero_or_more_optional(self):
parser = argparse.ArgumentParser()
parser.add_argument('x', nargs='*', choices=('x', 'y'))
args = parser.parse_args([])
self.assertEqual(NS(x=[]), args)
# ===========================
# parse_intermixed_args tests
# ===========================