There was an error while loading. Please reload this page.
2 parents df65f31 + c4928fc commit e6e9ec7Copy full SHA for e6e9ec7
2 files changed
Lib/test/test_unparse.py
@@ -344,6 +344,20 @@ def test_simple_expressions_parens(self):
344
self.check_src_roundtrip("call((yield x))")
345
self.check_src_roundtrip("return x + (yield x)")
346
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
+
361
def test_docstrings(self):
362
docstrings = (
363
'"""simple doc string"""',
Misc/NEWS.d/next/Library/2020-03-07-16-44-51.bpo-39889.3RYqeX.rst
@@ -0,0 +1,3 @@
1
+Fixed :func:`ast.unparse` for extended slices containing a single element
2
+(e.g. ``a[i:j,]``). Remove redundant tuples when index with a tuple (e.g.
3
+``a[i, j]``).
0 commit comments