diff options
author | Batuhan Taskaya <isidentical@gmail.com> | 2021-05-15 12:55:53 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-15 12:55:53 (GMT) |
commit | e4e931a67e49cf3c61263dc94fb0806c34f972cd (patch) | |
tree | 0ee2654289c0e1607123e8b17f52f857581c1352 /Lib/test/test_unparse.py | |
parent | 4aa63d65a9971d14f1a2131b989dca0dab514a9d (diff) | |
download | cpython-e4e931a67e49cf3c61263dc94fb0806c34f972cd.zip cpython-e4e931a67e49cf3c61263dc94fb0806c34f972cd.tar.gz cpython-e4e931a67e49cf3c61263dc94fb0806c34f972cd.tar.bz2 |
bpo-44081: improve ast.unparse() for lambdas with no parameters (GH-26000)
Diffstat (limited to 'Lib/test/test_unparse.py')
-rw-r--r-- | Lib/test/test_unparse.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_unparse.py b/Lib/test/test_unparse.py index 534431b..4d3340e 100644 --- a/Lib/test/test_unparse.py +++ b/Lib/test/test_unparse.py @@ -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.""" |