summaryrefslogtreecommitdiff
path: root/tests/test_domain_py.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-10-04 10:31:02 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2020-10-05 01:08:14 +0900
commitcc941db40b946534da8897a29631325d96313a6e (patch)
tree62bb189a3192dee3c1af396ba2a853925c6fc4ff /tests/test_domain_py.py
parent0b32e72635f6e117824b5cba3b8b38254a6a2644 (diff)
downloadsphinx-git-cc941db40b946534da8897a29631325d96313a6e.tar.gz
Fix #8255: py domain: number in defarg is changed to decimal
Number literals in default argument value is converted to decimal form unexpectedly by AST module. This fixes the signature parsing code to recosntruct it correctly. Note: This is only available in Python 3.8+.
Diffstat (limited to 'tests/test_domain_py.py')
-rw-r--r--tests/test_domain_py.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/test_domain_py.py b/tests/test_domain_py.py
index b98f37912..8040af9cc 100644
--- a/tests/test_domain_py.py
+++ b/tests/test_domain_py.py
@@ -386,6 +386,19 @@ def test_pyfunction_signature_full_py38(app):
[desc_parameter, desc_sig_operator, "/"])])
+@pytest.mark.skipif(sys.version_info < (3, 8), reason='python 3.8+ is required.')
+def test_pyfunction_with_number_literals(app):
+ text = ".. py:function:: hello(age=0x10, height=1_6_0)"
+ doctree = restructuredtext.parse(app, text)
+ assert_node(doctree[1][0][1],
+ [desc_parameterlist, ([desc_parameter, ([desc_sig_name, "age"],
+ [desc_sig_operator, "="],
+ [nodes.inline, "0x10"])],
+ [desc_parameter, ([desc_sig_name, "height"],
+ [desc_sig_operator, "="],
+ [nodes.inline, "1_6_0"])])])
+
+
def test_optional_pyfunction_signature(app):
text = ".. py:function:: compile(source [, filename [, symbol]]) -> ast object"
doctree = restructuredtext.parse(app, text)