summaryrefslogtreecommitdiffstats
path: root/Lib/lib2to3/tests
diff options
context:
space:
mode:
authorGregory P. Smith ext:(%20%5BGoogle%20Inc.%5D) <greg@krypto.org>2016-09-10 01:19:51 (GMT)
committerGregory P. Smith ext:(%20%5BGoogle%20Inc.%5D) <greg@krypto.org>2016-09-10 01:19:51 (GMT)
commit3b822d6c89ac6dffe5304adf0ce77c2d42406338 (patch)
tree9611fd543334e146032283448ecff2610ebd985a /Lib/lib2to3/tests
parent50a903de4cc050d0d4d3a02ab13036421909e4cf (diff)
parent28325749c01815097aa2bc06508004a1f894c279 (diff)
downloadcpython-3b822d6c89ac6dffe5304adf0ce77c2d42406338.zip
cpython-3b822d6c89ac6dffe5304adf0ce77c2d42406338.tar.gz
cpython-3b822d6c89ac6dffe5304adf0ce77c2d42406338.tar.bz2
Issue #25969: Update the lib2to3 grammar to handle the unpacking
generalizations added in 3.5.
Diffstat (limited to 'Lib/lib2to3/tests')
-rw-r--r--Lib/lib2to3/tests/test_fixers.py4
-rw-r--r--Lib/lib2to3/tests/test_parser.py35
2 files changed, 39 insertions, 0 deletions
diff --git a/Lib/lib2to3/tests/test_fixers.py b/Lib/lib2to3/tests/test_fixers.py
index f349c65..b3f2680 100644
--- a/Lib/lib2to3/tests/test_fixers.py
+++ b/Lib/lib2to3/tests/test_fixers.py
@@ -259,6 +259,10 @@ class Test_apply(FixerTestCase):
s = """apply(f, *args)"""
self.unchanged(s)
+ def test_unchanged_6b(self):
+ s = """apply(f, **kwds)"""
+ self.unchanged(s)
+
def test_unchanged_7(self):
s = """apply(func=f, args=args, kwds=kwds)"""
self.unchanged(s)
diff --git a/Lib/lib2to3/tests/test_parser.py b/Lib/lib2to3/tests/test_parser.py
index 50e78a0..9a969e8 100644
--- a/Lib/lib2to3/tests/test_parser.py
+++ b/Lib/lib2to3/tests/test_parser.py
@@ -226,6 +226,41 @@ class TestRaiseChanges(GrammarTest):
self.invalid_syntax("raise E from")
+# Modelled after Lib/test/test_grammar.py:TokenTests.test_funcdef issue2292
+# and Lib/test/text_parser.py test_list_displays, test_set_displays,
+# test_dict_displays, test_argument_unpacking, ... changes.
+class TestUnpackingGeneralizations(GrammarTest):
+ def test_mid_positional_star(self):
+ self.validate("""func(1, *(2, 3), 4)""")
+
+ def test_double_star_dict_literal(self):
+ self.validate("""func(**{'eggs':'scrambled', 'spam':'fried'})""")
+
+ def test_double_star_dict_literal_after_keywords(self):
+ self.validate("""func(spam='fried', **{'eggs':'scrambled'})""")
+
+ def test_list_display(self):
+ self.validate("""[*{2}, 3, *[4]]""")
+
+ def test_set_display(self):
+ self.validate("""{*{2}, 3, *[4]}""")
+
+ def test_dict_display_1(self):
+ self.validate("""{**{}}""")
+
+ def test_dict_display_2(self):
+ self.validate("""{**{}, 3:4, **{5:6, 7:8}}""")
+
+ def test_argument_unpacking_1(self):
+ self.validate("""f(a, *b, *c, d)""")
+
+ def test_argument_unpacking_2(self):
+ self.validate("""f(**a, **b)""")
+
+ def test_argument_unpacking_3(self):
+ self.validate("""f(2, *a, *b, **b, **c, **d)""")
+
+
# Adapted from Python 3's Lib/test/test_grammar.py:GrammarTests.testFuncdef
class TestFunctionAnnotations(GrammarTest):
def test_1(self):