Skip to content

Commit

Permalink
added extra test to hit pydra/utils/typing.py L702
Browse files Browse the repository at this point in the history
  • Loading branch information
tclose committed Sep 25, 2023
1 parent 1c60b14 commit fd0e6f1
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions pydra/utils/tests/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,32 @@ def test_generic_is_subclass3():
assert not TypeParser.is_subclass(ty.List[float], ty.List[int])


def test_generic_is_subclass4():
class MyTuple(tuple):
pass

class A:
pass

class B(A):
pass

assert TypeParser.is_subclass(MyTuple[A], ty.Tuple[A])
assert TypeParser.is_subclass(ty.Tuple[B], ty.Tuple[A])
assert TypeParser.is_subclass(MyTuple[B], ty.Tuple[A])
assert not TypeParser.is_subclass(ty.Tuple[A], ty.Tuple[B])
assert not TypeParser.is_subclass(ty.Tuple[A], MyTuple[A])
assert not TypeParser.is_subclass(MyTuple[A], ty.Tuple[B])
assert TypeParser.is_subclass(MyTuple[A, int], ty.Tuple[A, int])
assert TypeParser.is_subclass(ty.Tuple[B, int], ty.Tuple[A, int])
assert TypeParser.is_subclass(MyTuple[B, int], ty.Tuple[A, int])
assert TypeParser.is_subclass(MyTuple[int, B], ty.Tuple[int, A])
assert not TypeParser.is_subclass(MyTuple[B, int], ty.Tuple[int, A])
assert not TypeParser.is_subclass(MyTuple[int, B], ty.Tuple[A, int])
assert not TypeParser.is_subclass(MyTuple[B, int], ty.Tuple[A])
assert not TypeParser.is_subclass(MyTuple[B], ty.Tuple[A, int])


def test_type_is_instance1():
assert TypeParser.is_instance(File, ty.Type[File])

Expand Down

0 comments on commit fd0e6f1

Please sign in to comment.