bpo-39889: Fix ast.unparse() for subscript. (GH-18824)

This commit is contained in:
Serhiy Storchaka 2020-03-07 17:25:32 +02:00 committed by GitHub
parent 31350f9af0
commit c4928fc1a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 2 deletions

View file

@ -344,6 +344,20 @@ class CosmeticTestCase(ASTTestCase):
self.check_src_roundtrip("call((yield x))")
self.check_src_roundtrip("return x + (yield x)")
def test_subscript(self):
self.check_src_roundtrip("a[i]")
self.check_src_roundtrip("a[i,]")
self.check_src_roundtrip("a[i, j]")
self.check_src_roundtrip("a[()]")
self.check_src_roundtrip("a[i:j]")
self.check_src_roundtrip("a[:j]")
self.check_src_roundtrip("a[i:]")
self.check_src_roundtrip("a[i:j:k]")
self.check_src_roundtrip("a[:j:k]")
self.check_src_roundtrip("a[i::k]")
self.check_src_roundtrip("a[i:j,]")
self.check_src_roundtrip("a[i:j, k]")
def test_docstrings(self):
docstrings = (
'"""simple doc string"""',