bpo-44081: improve ast.unparse() for lambdas with no parameters (GH-26000)

This commit is contained in:
Batuhan Taskaya 2021-05-15 15:55:53 +03:00 committed by GitHub
parent 4aa63d65a9
commit e4e931a67e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 5 deletions

View file

@ -531,6 +531,17 @@ class CosmeticTestCase(ASTTestCase):
self.check_src_roundtrip("a[1, 2]")
self.check_src_roundtrip("a[(1, *a)]")
def test_lambda_parameters(self):
self.check_src_roundtrip("lambda: something")
self.check_src_roundtrip("four = lambda: 2 + 2")
self.check_src_roundtrip("lambda x: x * 2")
self.check_src_roundtrip("square = lambda n: n ** 2")
self.check_src_roundtrip("lambda x, y: x + y")
self.check_src_roundtrip("add = lambda x, y: x + y")
self.check_src_roundtrip("lambda x, y, /, z, q, *, u: None")
self.check_src_roundtrip("lambda x, *y, **z: None")
class DirectoryTestCase(ASTTestCase):
"""Test roundtrip behaviour on all files in Lib and Lib/test."""