diff options
author | Ćukasz Langa <lukasz@langa.pl> | 2018-03-13 07:44:49 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-13 07:44:49 (GMT) |
commit | b51f5de71163f096d2d5229ede5379cdb284f651 (patch) | |
tree | 2e2cd21070d32c6000c68ad7143295f10685c75d /Lib/lib2to3/tests | |
parent | a34510a4c562b4b23c7f9da6ff6e2318484f5f1a (diff) | |
download | cpython-b51f5de71163f096d2d5229ede5379cdb284f651.zip cpython-b51f5de71163f096d2d5229ede5379cdb284f651.tar.gz cpython-b51f5de71163f096d2d5229ede5379cdb284f651.tar.bz2 |
bpo-33064: lib2to3: support trailing comma after *args and **kwargs (#6096)
New tests also added.
I also made the comments in line with the builtin Grammar/Grammar. PEP 306 was
withdrawn, Kees Blom's railroad program has been lost to the sands of time for
at least 16 years now (I found a python-dev post from people looking for it).
Diffstat (limited to 'Lib/lib2to3/tests')
-rw-r--r-- | Lib/lib2to3/tests/test_parser.py | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/Lib/lib2to3/tests/test_parser.py b/Lib/lib2to3/tests/test_parser.py index 0cbba26..cec2f98 100644 --- a/Lib/lib2to3/tests/test_parser.py +++ b/Lib/lib2to3/tests/test_parser.py @@ -9,7 +9,6 @@ test_grammar.py files from both Python 2 and Python 3. # Testing imports from . import support from .support import driver, driver_no_print_statement -from test.support import verbose # Python imports import difflib @@ -22,7 +21,6 @@ import subprocess import sys import tempfile import unittest -import warnings # Local imports from lib2to3.pgen2 import driver as pgen2_driver @@ -305,6 +303,38 @@ class TestFunctionAnnotations(GrammarTest): *g:6, h:7, i=8, j:9=10, **k:11) -> 12: pass""" self.validate(s) + def test_9(self): + s = """def f( + a: str, + b: int, + *, + c: bool = False, + **kwargs, + ) -> None: + call(c=c, **kwargs,)""" + self.validate(s) + + def test_10(self): + s = """def f( + a: str, + ) -> None: + call(a,)""" + self.validate(s) + + def test_11(self): + s = """def f( + a: str = '', + ) -> None: + call(a=a,)""" + self.validate(s) + + def test_12(self): + s = """def f( + *args: str, + ) -> None: + call(*args,)""" + self.validate(s) + # Adapted from Python 3's Lib/test/test_grammar.py:GrammarTests.test_var_annot class TestVarAnnotations(GrammarTest): @@ -407,7 +437,7 @@ class TestClassDef(GrammarTest): self.validate("class B(t, *args): pass") self.validate("class B(t, **kwargs): pass") self.validate("class B(t, *args, **kwargs): pass") - self.validate("class B(t, y=9, *args, **kwargs): pass") + self.validate("class B(t, y=9, *args, **kwargs,): pass") class TestParserIdempotency(support.TestCase): |