@@ -523,6 +523,12 @@ def test_classattrs(self):
523523 self .assertIs (ast .Constant (None ).value , None )
524524 self .assertIs (ast .Constant (...).value , ...)
525525
526+ with self .assertWarns (DeprecationWarning ):
527+ ast .Tuple ().dims
528+
529+ with self .assertWarns (DeprecationWarning ):
530+ ast .Tuple ().dims = 3
531+
526532 def test_constant_subclasses (self ):
527533 class N (ast .Constant ):
528534 def __init__ (self , * args , ** kwargs ):
@@ -1100,6 +1106,38 @@ def test_tstring(self):
11001106 self .assertIsInstance (tree .body [0 ].value .values [0 ], ast .Constant )
11011107 self .assertIsInstance (tree .body [0 ].value .values [1 ], ast .Interpolation )
11021108
1109+ def test_deprecated (self ):
1110+ with self .assertWarns (DeprecationWarning ):
1111+ ast .slice
1112+
1113+ with self .assertWarns (DeprecationWarning ):
1114+ ast .Index
1115+
1116+ with self .assertWarns (DeprecationWarning ):
1117+ ast .ExtSlice
1118+
1119+ with self .assertWarns (DeprecationWarning ):
1120+ ast .Suite
1121+
1122+ with self .assertWarns (DeprecationWarning ):
1123+ ast .AugLoad
1124+
1125+ with self .assertWarns (DeprecationWarning ):
1126+ ast .AugStore
1127+
1128+ with self .assertWarns (DeprecationWarning ):
1129+ ast .Param
1130+
1131+ namespace = {}
1132+ exec ("from ast import *" , namespace )
1133+ self .assertNotIn ("slice" , namespace )
1134+ self .assertNotIn ("Index" , namespace )
1135+ self .assertNotIn ("ExtSlice" , namespace )
1136+ self .assertNotIn ("Suite" , namespace )
1137+ self .assertNotIn ("AugLoad" , namespace )
1138+ self .assertNotIn ("AugStore" , namespace )
1139+ self .assertNotIn ("Param" , namespace )
1140+
11031141 def test_filter_syntax_warnings_by_module (self ):
11041142 filename = support .findfile ('test_import/data/syntax_warnings.py' )
11051143 with open (filename , 'rb' ) as f :
@@ -1139,8 +1177,9 @@ def iter_ast_classes():
11391177 def do (cls ):
11401178 if cls .__module__ != 'ast' :
11411179 return
1142- if cls is ast .Index :
1143- return
1180+ with warnings .catch_warnings (action = "ignore" , category = DeprecationWarning ):
1181+ if cls is ast .Index :
1182+ return
11441183 # Don't attempt to create instances of abstract AST nodes
11451184 if _ast ._is_abstract (cls ):
11461185 return
0 commit comments