From fd0e6f1690f9e0ed59bee5ec98815106cce1a018 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Mon, 25 Sep 2023 14:21:04 +1000 Subject: [PATCH] added extra test to hit pydra/utils/typing.py L702 --- pydra/utils/tests/test_typing.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/pydra/utils/tests/test_typing.py b/pydra/utils/tests/test_typing.py index f0a9f3790..7e3c84c4e 100644 --- a/pydra/utils/tests/test_typing.py +++ b/pydra/utils/tests/test_typing.py @@ -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])