33from typing import Union , Dict , List , TypeVar
44
55
6+ def check_equal (result , expected ):
7+ if len (result ) != len (expected ):
8+ return False
9+ for sig in result :
10+ if sig not in expected :
11+ return False
12+ return True
13+
14+
615class TestTypeAnnotations (unittest .TestCase ):
716
817 def test_get_func_annotations_exceptions (self ):
@@ -46,17 +55,6 @@ def func_three(a: Dict[int, str], b: str = "string", c: int = 1):
4655 with self .subTest (func = f .__name__ ):
4756 self .assertEqual (type_annotations .get_func_annotations (f ), expected )
4857
49- ''' def test_product_annotations(self):
50-
51- S = TypeVar('S', float, str)
52- annotations = ({'a': [int], 'b': [int, float], 'c': [S]}, {})
53- result = type_annotations.product_annotations(annotations)
54- expected = [[{'a': int, 'b': int, 'c': float}, {}],
55- [{'a': int, 'b': int, 'c': str}, {}],
56- [{'a': int, 'b': float, 'c': float}, {}],
57- [{'a': int, 'b': float, 'c': str}, {}]]
58- self.assertEqual(result, expected)'''
59-
6058 def test_convert_to_sig_list (self ):
6159 T = TypeVar ('T' , int , str )
6260 S = TypeVar ('S' , float , str )
@@ -133,7 +131,8 @@ def test_get_internal_typevars(self):
133131 {'a' : str , 'b' : Dict [str , bool ]}]
134132
135133 result = type_annotations .get_internal_typevars (signature )
136- self .assertEqual (result , expected )
134+
135+ self .assertTrue (check_equal (result , expected ))
137136
138137 def test_update_sig (self ):
139138 T = TypeVar ('T' , int , str )
@@ -158,7 +157,8 @@ def test_expand_typevars(self):
158157 {'a' : str , 'b' : Dict [str , bool ], 'c' : int }]
159158
160159 result = type_annotations .expand_typevars (sig , unique_typevars )
161- self .assertEqual (result , expected )
160+
161+ self .assertTrue (check_equal (result , expected ))
162162
163163 def test_product_annotations (self ):
164164
@@ -176,12 +176,10 @@ def test_product_annotations(self):
176176 [{'a' : int , 'b' : Dict [int , bool ], 'c' : bool , 'd' : int }, {'d' : 3 }],
177177 [{'a' : str , 'b' : Dict [str , float ], 'c' : bool , 'd' : int }, {'d' : 3 }],
178178 [{'a' : str , 'b' : Dict [str , bool ], 'c' : bool , 'd' : int }, {'d' : 3 }]]
179-
180179
181180 result = type_annotations .product_annotations (annotations )
182- #print(result)
183-
184- self .assertEqual (result , expected )
181+
182+ self .assertTrue (check_equal (result , expected ))
185183
186184
187185if __name__ == '__main__' :
0 commit comments