Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit test to cover non built-in GenericAlias types #25091

Merged
merged 1 commit into from
Jan 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions sdks/python/apache_beam/typehints/typehints_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ class SubClass(SuperClass):
pass


T = typing.TypeVar('T')


class NonBuiltInGeneric(typing.NamedTuple('Entry', [('Field1', T),
('Field2', T)]),
typing.Generic[T]):
pass


class TypeHintTestCase(unittest.TestCase):
def assertCompatible(self, base, sub): # pylint: disable=invalid-name
base, sub = native_type_compatibility.convert_to_beam_types([base, sub])
Expand Down Expand Up @@ -1645,5 +1654,12 @@ def test_pipe_operator_as_union(self):
native_type_compatibility.convert_to_beam_type(type_b))


class TestNonBuiltInGenerics(unittest.TestCase):
def test_no_error_thrown(self):
input = NonBuiltInGeneric[str]
output = typehints.normalize(input)
self.assertEqual(input, output)


if __name__ == '__main__':
unittest.main()