Skip to content

Commit 72c9468

Browse files
committed
add test case for non built-in generic
1 parent 6570cc4 commit 72c9468

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

sdks/python/apache_beam/typehints/typehints_test.py

+16
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,15 @@ class SubClass(SuperClass):
104104
pass
105105

106106

107+
T = typing.TypeVar('T')
108+
109+
110+
class NonBuiltInGeneric(typing.NamedTuple('Entry', [('Field1', T),
111+
('Field2', T)]),
112+
typing.Generic[T]):
113+
pass
114+
115+
107116
class TypeHintTestCase(unittest.TestCase):
108117
def assertCompatible(self, base, sub): # pylint: disable=invalid-name
109118
base, sub = native_type_compatibility.convert_to_beam_types([base, sub])
@@ -1643,5 +1652,12 @@ def test_pipe_operator_as_union(self):
16431652
native_type_compatibility.convert_to_beam_type(type_b))
16441653

16451654

1655+
class TestNonBuiltInGenerics(unittest.TestCase):
1656+
def test_no_error_thrown(self):
1657+
input = NonBuiltInGeneric[str]
1658+
output = typehints.normalize(input)
1659+
self.assertEqual(input, output)
1660+
1661+
16461662
if __name__ == '__main__':
16471663
unittest.main()

0 commit comments

Comments
 (0)