@@ -7456,40 +7456,27 @@ def test_wrong_amount_of_parameters(self):
74567456 CallablePT = TypeAliasType ("CallablePT" , Callable [P , T ], type_params = (P , T ))
74577457
74587458 # Not enough parameters
7459- not_enough = TwoT [int ]
7460- self .assertEqual (get_args (not_enough ), (int ,))
7461- self .assertEqual (not_enough .__parameters__ , ())
7462-
7463- not_enough2 = TwoT [T ]
7464- self .assertEqual (get_args (not_enough2 ), (T ,))
7465- self .assertEqual (not_enough2 .__parameters__ , (T ,))
7466-
7467- callable_not_enough = CallablePT [int ]
7468- self .assertEqual (get_args (callable_not_enough ), (int , ))
7469- self .assertEqual (callable_not_enough .__parameters__ , ())
7470-
7471- # Too many
7472- too_many = ListOrSetT [int , bool ]
7473- self .assertEqual (get_args (too_many ), (int , bool ))
7474- self .assertEqual (too_many .__parameters__ , ())
7475-
7476- callable_too_many = CallablePT [str , float , int ]
7477- self .assertEqual (get_args (callable_too_many ), (str , float , int ))
7478- self .assertEqual (callable_too_many .__parameters__ , ())
7479-
7480- # Check if TypeVar is still present even if over substituted
7481- too_manyT = ListOrSetT [int , T ]
7482- self .assertEqual (get_args (too_manyT ), (int , T ))
7483- self .assertEqual (too_manyT .__parameters__ , (T , ))
7484-
7485- # With and without list for ParamSpec
7486- callable_too_manyT = CallablePT [str , float , T ]
7487- self .assertEqual (get_args (callable_too_manyT ), (str , float , T ))
7488- self .assertEqual (callable_too_manyT .__parameters__ , (T , ))
7489-
7490- callable_too_manyT2 = CallablePT [[str ], float , int , T2 ]
7491- self .assertEqual (get_args (callable_too_manyT2 ), ([str ], float , int , T2 ))
7492- self .assertEqual (callable_too_manyT2 .__parameters__ , (T2 , ))
7459+ test_cases = [
7460+ # not_enough
7461+ (TwoT [int ], [(int ,), ()]),
7462+ (TwoT [T ], [(T ,), (T ,)]),
7463+ # callable and not enough
7464+ (CallablePT [int ], [(int ,), ()]),
7465+ # too many
7466+ (ListOrSetT [int , bool ], [(int , bool ), ()]),
7467+ # callable and too many
7468+ (CallablePT [str , float , int ], [(str , float , int ), ()]),
7469+ # Check if TypeVar is still present even if over substituted
7470+ (ListOrSetT [int , T ], [(int , T ), (T ,)]),
7471+ # With and without list for ParamSpec
7472+ (CallablePT [str , float , T ], [(str , float , T ), (T ,)]),
7473+ (CallablePT [[str ], float , int , T2 ], [([str ], float , int , T2 ), (T2 ,)]),
7474+ ]
7475+
7476+ for index , (alias , [expected_args , expected_params ]) in enumerate (test_cases ):
7477+ with self .subTest (index = index , alias = alias ):
7478+ self .assertEqual (get_args (alias ), expected_args )
7479+ self .assertEqual (alias .__parameters__ , expected_params )
74937480
74947481 def test_list_argument (self ):
74957482 # NOTE: These cases could be seen as valid but result in a parameterless
0 commit comments