Skip to content

Commit 7ed2e11

Browse files
committed
added extra test to hit pydra/utils/typing.py L702
1 parent 957a0d7 commit 7ed2e11

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

pydra/utils/tests/test_typing.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,32 @@ def test_generic_is_subclass3():
717717
assert not TypeParser.is_subclass(ty.List[float], ty.List[int])
718718

719719

720+
def test_generic_is_subclass4():
721+
class MyTuple(tuple):
722+
pass
723+
724+
class A:
725+
pass
726+
727+
class B(A):
728+
pass
729+
730+
assert TypeParser.is_subclass(MyTuple[A], ty.Tuple[A])
731+
assert TypeParser.is_subclass(ty.Tuple[B], ty.Tuple[A])
732+
assert TypeParser.is_subclass(MyTuple[B], ty.Tuple[A])
733+
assert not TypeParser.is_subclass(ty.Tuple[A], ty.Tuple[B])
734+
assert not TypeParser.is_subclass(ty.Tuple[A], MyTuple[A])
735+
assert not TypeParser.is_subclass(MyTuple[A], ty.Tuple[B])
736+
assert TypeParser.is_subclass(MyTuple[A, int], ty.Tuple[A, int])
737+
assert TypeParser.is_subclass(ty.Tuple[B, int], ty.Tuple[A, int])
738+
assert TypeParser.is_subclass(MyTuple[B, int], ty.Tuple[A, int])
739+
assert TypeParser.is_subclass(MyTuple[int, B], ty.Tuple[int, A])
740+
assert not TypeParser.is_subclass(MyTuple[B, int], ty.Tuple[int, A])
741+
assert not TypeParser.is_subclass(MyTuple[int, B], ty.Tuple[A, int])
742+
assert not TypeParser.is_subclass(MyTuple[B, int], ty.Tuple[A])
743+
assert not TypeParser.is_subclass(MyTuple[B], ty.Tuple[A, int])
744+
745+
720746
def test_type_is_instance1():
721747
assert TypeParser.is_instance(File, ty.Type[File])
722748

0 commit comments

Comments
 (0)