summaryrefslogtreecommitdiff
path: root/tests/test_pycode_ast.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-02-16 12:05:59 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2020-02-16 12:57:14 +0900
commit76b492aa982c771af0204cf2c0d1212f165aa754 (patch)
treeef0eadb00e9d3041a94b69a29dfcb2cf0fb90ecd /tests/test_pycode_ast.py
parent8576e97e34a9b39189cb4e8188407002cdab1a27 (diff)
downloadsphinx-git-76b492aa982c771af0204cf2c0d1212f165aa754.tar.gz
py domain: Support lambda functions in function signature
Diffstat (limited to 'tests/test_pycode_ast.py')
-rw-r--r--tests/test_pycode_ast.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/test_pycode_ast.py b/tests/test_pycode_ast.py
index af7e34a86..d195e5c6f 100644
--- a/tests/test_pycode_ast.py
+++ b/tests/test_pycode_ast.py
@@ -8,6 +8,8 @@
:license: BSD, see LICENSE for details.
"""
+import sys
+
import pytest
from sphinx.pycode import ast
@@ -23,7 +25,7 @@ from sphinx.pycode import ast
("...", "..."), # Ellipsis
("Tuple[int, int]", "Tuple[int, int]"), # Index, Subscript
("lambda x, y: x + y",
- "<function <lambda>>"), # Lambda
+ "lambda x, y: ..."), # Lambda
("[1, 2, 3]", "[1, 2, 3]"), # List
("sys", "sys"), # Name, NameConstant
("1234", "1234"), # Num
@@ -38,3 +40,11 @@ def test_unparse(source, expected):
def test_unparse_None():
assert ast.unparse(None) is None
+
+
+@pytest.mark.skipif(sys.version_info < (3, 8), reason='python 3.8+ is required.')
+def test_unparse_py38():
+ source = "lambda x=0, /, y=1, *args, z, **kwargs: x + y + z"
+ expected = "lambda x=0, /, y=1, *args, z, **kwargs: ..."
+ module = ast.parse(source)
+ assert ast.unparse(module.body[0].value) == expected