@@ -153,22 +153,6 @@ def test_optimization_levels__debug__(self):
153153                        self .assertIsInstance (res .body [0 ].value , ast .Name )
154154                        self .assertEqual (res .body [0 ].value .id , expected )
155155
156-     def  test_optimization_levels_const_folding (self ):
157-         folded  =  ('Expr' , (1 , 0 , 1 , 6 ), ('Constant' , (1 , 0 , 1 , 6 ), (1 , 2 ), None ))
158-         not_folded  =  ('Expr' , (1 , 0 , 1 , 6 ),
159-                          ('Tuple' , (1 , 0 , 1 , 6 ),
160-                              [('Constant' , (1 , 1 , 1 , 2 ), 1 , None ),
161-                              ('Constant' , (1 , 4 , 1 , 5 ), 2 , None )], ('Load' ,)))
162- 
163-         cases  =  [(- 1 , not_folded ), (0 , not_folded ), (1 , folded ), (2 , folded )]
164-         for  (optval , expected ) in  cases :
165-             with  self .subTest (optval = optval ):
166-                 tree1  =  ast .parse ("(1, 2)" , optimize = optval )
167-                 tree2  =  ast .parse (ast .parse ("(1, 2)" ), optimize = optval )
168-                 for  tree  in  [tree1 , tree2 ]:
169-                     res  =  to_tuple (tree .body [0 ])
170-                     self .assertEqual (res , expected )
171- 
172156    def  test_invalid_position_information (self ):
173157        invalid_linenos  =  [
174158            (10 , 1 ), (- 10 , - 11 ), (10 , - 11 ), (- 5 , - 2 ), (- 5 , 1 )
@@ -3138,101 +3122,6 @@ def test_folding_format(self):
31383122
31393123        self .assert_ast (code , non_optimized_target , optimized_target )
31403124
3141- 
3142-     def  test_folding_tuple (self ):
3143-         code  =  "(1,)" 
3144- 
3145-         non_optimized_target  =  self .wrap_expr (ast .Tuple (elts = [ast .Constant (1 )]))
3146-         optimized_target  =  self .wrap_expr (ast .Constant (value = (1 ,)))
3147- 
3148-         self .assert_ast (code , non_optimized_target , optimized_target )
3149- 
3150-     def  test_folding_type_param_in_function_def (self ):
3151-         code  =  "def foo[%s = (1, 2)](): pass" 
3152- 
3153-         unoptimized_tuple  =  ast .Tuple (elts = [ast .Constant (1 ), ast .Constant (2 )])
3154-         unoptimized_type_params  =  [
3155-             ("T" , "T" , ast .TypeVar ),
3156-             ("**P" , "P" , ast .ParamSpec ),
3157-             ("*Ts" , "Ts" , ast .TypeVarTuple ),
3158-         ]
3159- 
3160-         for  type , name , type_param  in  unoptimized_type_params :
3161-             result_code  =  code  %  type 
3162-             optimized_target  =  self .wrap_statement (
3163-                 ast .FunctionDef (
3164-                     name = 'foo' ,
3165-                     args = ast .arguments (),
3166-                     body = [ast .Pass ()],
3167-                     type_params = [type_param (name = name , default_value = ast .Constant ((1 , 2 )))]
3168-                 )
3169-             )
3170-             non_optimized_target  =  self .wrap_statement (
3171-                 ast .FunctionDef (
3172-                     name = 'foo' ,
3173-                     args = ast .arguments (),
3174-                     body = [ast .Pass ()],
3175-                     type_params = [type_param (name = name , default_value = unoptimized_tuple )]
3176-                 )
3177-             )
3178-             self .assert_ast (result_code , non_optimized_target , optimized_target )
3179- 
3180-     def  test_folding_type_param_in_class_def (self ):
3181-         code  =  "class foo[%s = (1, 2)]: pass" 
3182- 
3183-         unoptimized_tuple  =  ast .Tuple (elts = [ast .Constant (1 ), ast .Constant (2 )])
3184-         unoptimized_type_params  =  [
3185-             ("T" , "T" , ast .TypeVar ),
3186-             ("**P" , "P" , ast .ParamSpec ),
3187-             ("*Ts" , "Ts" , ast .TypeVarTuple ),
3188-         ]
3189- 
3190-         for  type , name , type_param  in  unoptimized_type_params :
3191-             result_code  =  code  %  type 
3192-             optimized_target  =  self .wrap_statement (
3193-                 ast .ClassDef (
3194-                     name = 'foo' ,
3195-                     body = [ast .Pass ()],
3196-                     type_params = [type_param (name = name , default_value = ast .Constant ((1 , 2 )))]
3197-                 )
3198-             )
3199-             non_optimized_target  =  self .wrap_statement (
3200-                 ast .ClassDef (
3201-                     name = 'foo' ,
3202-                     body = [ast .Pass ()],
3203-                     type_params = [type_param (name = name , default_value = unoptimized_tuple )]
3204-                 )
3205-             )
3206-             self .assert_ast (result_code , non_optimized_target , optimized_target )
3207- 
3208-     def  test_folding_type_param_in_type_alias (self ):
3209-         code  =  "type foo[%s = (1, 2)] = 1" 
3210- 
3211-         unoptimized_tuple  =  ast .Tuple (elts = [ast .Constant (1 ), ast .Constant (2 )])
3212-         unoptimized_type_params  =  [
3213-             ("T" , "T" , ast .TypeVar ),
3214-             ("**P" , "P" , ast .ParamSpec ),
3215-             ("*Ts" , "Ts" , ast .TypeVarTuple ),
3216-         ]
3217- 
3218-         for  type , name , type_param  in  unoptimized_type_params :
3219-             result_code  =  code  %  type 
3220-             optimized_target  =  self .wrap_statement (
3221-                 ast .TypeAlias (
3222-                     name = ast .Name (id = 'foo' , ctx = ast .Store ()),
3223-                     type_params = [type_param (name = name , default_value = ast .Constant ((1 , 2 )))],
3224-                     value = ast .Constant (value = 1 ),
3225-                 )
3226-             )
3227-             non_optimized_target  =  self .wrap_statement (
3228-                 ast .TypeAlias (
3229-                     name = ast .Name (id = 'foo' , ctx = ast .Store ()),
3230-                     type_params = [type_param (name = name , default_value = unoptimized_tuple )],
3231-                     value = ast .Constant (value = 1 ),
3232-                 )
3233-             )
3234-             self .assert_ast (result_code , non_optimized_target , optimized_target )
3235- 
32363125    def  test_folding_match_case_allowed_expressions (self ):
32373126        def  get_match_case_values (node ):
32383127            result  =  []
0 commit comments