@@ -280,6 +280,20 @@ def test_dict_unpacking_in_dict(self):
280280 self .check_ast_roundtrip (r"""{**{'y': 2}, 'x': 1}""" )
281281 self .check_ast_roundtrip (r"""{**{'y': 2}, **{'x': 1}}""" )
282282
283+ def test_ext_slices (self ):
284+ self .check_ast_roundtrip ("a[i]" )
285+ self .check_ast_roundtrip ("a[i,]" )
286+ self .check_ast_roundtrip ("a[i, j]" )
287+ self .check_ast_roundtrip ("a[()]" )
288+ self .check_ast_roundtrip ("a[i:j]" )
289+ self .check_ast_roundtrip ("a[:j]" )
290+ self .check_ast_roundtrip ("a[i:]" )
291+ self .check_ast_roundtrip ("a[i:j:k]" )
292+ self .check_ast_roundtrip ("a[:j:k]" )
293+ self .check_ast_roundtrip ("a[i::k]" )
294+ self .check_ast_roundtrip ("a[i:j,]" )
295+ self .check_ast_roundtrip ("a[i:j, k]" )
296+
283297 def test_invalid_raise (self ):
284298 self .check_invalid (ast .Raise (exc = None , cause = ast .Name (id = "X" )))
285299
@@ -310,6 +324,12 @@ def test_docstrings(self):
310324 # check as Module docstrings for easy testing
311325 self .check_ast_roundtrip (f"'{ docstring } '" )
312326
327+ def test_constant_tuples (self ):
328+ self .check_src_roundtrip (ast .Constant (value = (1 ,), kind = None ), "(1,)" )
329+ self .check_src_roundtrip (
330+ ast .Constant (value = (1 , 2 , 3 ), kind = None ), "(1, 2, 3)"
331+ )
332+
313333
314334class CosmeticTestCase (ASTTestCase ):
315335 """Test if there are cosmetic issues caused by unnecesary additions"""
@@ -344,20 +364,6 @@ def test_simple_expressions_parens(self):
344364 self .check_src_roundtrip ("call((yield x))" )
345365 self .check_src_roundtrip ("return x + (yield x)" )
346366
347- def test_subscript (self ):
348- self .check_src_roundtrip ("a[i]" )
349- self .check_src_roundtrip ("a[i,]" )
350- self .check_src_roundtrip ("a[i, j]" )
351- self .check_src_roundtrip ("a[()]" )
352- self .check_src_roundtrip ("a[i:j]" )
353- self .check_src_roundtrip ("a[:j]" )
354- self .check_src_roundtrip ("a[i:]" )
355- self .check_src_roundtrip ("a[i:j:k]" )
356- self .check_src_roundtrip ("a[:j:k]" )
357- self .check_src_roundtrip ("a[i::k]" )
358- self .check_src_roundtrip ("a[i:j,]" )
359- self .check_src_roundtrip ("a[i:j, k]" )
360-
361367 def test_docstrings (self ):
362368 docstrings = (
363369 '"""simple doc string"""' ,
0 commit comments