summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2020-03-07 16:55:32 (GMT)
committerGitHub <noreply@github.com>2020-03-07 16:55:32 (GMT)
commit92b72788ecf2ee5dfac780c7dfb5ee5350fc641d (patch)
tree275b322f60b15b95649a6687d787583019009e23 /Lib/test
parentd692d52f4aaeb6feaabb18f18d49907dd578fbeb (diff)
downloadcpython-92b72788ecf2ee5dfac780c7dfb5ee5350fc641d.zip
cpython-92b72788ecf2ee5dfac780c7dfb5ee5350fc641d.tar.gz
cpython-92b72788ecf2ee5dfac780c7dfb5ee5350fc641d.tar.bz2
[3.8] bpo-39889: Fix unparse.py for subscript. (GH-18824). (GH-18826)
(cherry picked from commit c4928fc1a853f3f84e2b4ec1253d0349137745e5)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_tools/test_unparse.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_tools/test_unparse.py b/Lib/test/test_tools/test_unparse.py
index a958ebb..d89cb09 100644
--- a/Lib/test/test_tools/test_unparse.py
+++ b/Lib/test/test_tools/test_unparse.py
@@ -265,6 +265,20 @@ class UnparseTestCase(ASTTestCase):
self.check_roundtrip(r"""{**{'y': 2}, 'x': 1}""")
self.check_roundtrip(r"""{**{'y': 2}, **{'x': 1}}""")
+ def test_subscript(self):
+ self.check_roundtrip("a[i]")
+ self.check_roundtrip("a[i,]")
+ self.check_roundtrip("a[i, j]")
+ self.check_roundtrip("a[()]")
+ self.check_roundtrip("a[i:j]")
+ self.check_roundtrip("a[:j]")
+ self.check_roundtrip("a[i:]")
+ self.check_roundtrip("a[i:j:k]")
+ self.check_roundtrip("a[:j:k]")
+ self.check_roundtrip("a[i::k]")
+ self.check_roundtrip("a[i:j,]")
+ self.check_roundtrip("a[i:j, k]")
+
class DirectoryTestCase(ASTTestCase):
"""Test roundtrip behaviour on all files in Lib and Lib/test."""