Skip to content

Commit 3d34688

Browse files
committed
Add test for List[Literal[...]] with action=append
1 parent 0f5af4e commit 3d34688

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tests/test_actions.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import sys
2-
from typing import List
2+
from typing import List, Literal
33
import unittest
44
from unittest import TestCase
55

@@ -99,6 +99,16 @@ def configure(self):
9999
args = AppendListIntTap().parse_args('--arg 3 --arg 4'.split())
100100
self.assertEqual(args.arg, [1, 2, 3, 4])
101101

102+
def test_actions_append_list_literal(self):
103+
class AppendListLiteralTap(Tap):
104+
arg: List[Literal['what', 'is', 'up', 'today']] = ['what', 'is']
105+
106+
def configure(self):
107+
self.add_argument('--arg', action='append')
108+
109+
args = AppendListLiteralTap().parse_args('--arg up --arg today'.split())
110+
self.assertEqual(args.arg, 'what is up today'.split())
111+
102112
def test_actions_append_untyped(self):
103113
class AppendListStrTap(Tap):
104114
arg = ['what', 'is']

0 commit comments

Comments
 (0)