diff options
Diffstat (limited to 'tests/test_domain_py.py')
-rw-r--r-- | tests/test_domain_py.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/test_domain_py.py b/tests/test_domain_py.py index a1e37fa5e..448c2c954 100644 --- a/tests/test_domain_py.py +++ b/tests/test_domain_py.py @@ -431,6 +431,20 @@ def test_pyfunction_with_number_literals(app): [nodes.inline, "1_6_0"])])]) +def test_pyfunction_with_union_type_operator(app): + text = ".. py:function:: hello(age: int | None)" + doctree = restructuredtext.parse(app, text) + assert_node(doctree[1][0][1], + [desc_parameterlist, ([desc_parameter, ([desc_sig_name, "age"], + [desc_sig_punctuation, ":"], + " ", + [desc_sig_name, ([pending_xref, "int"], + " ", + [desc_sig_punctuation, "|"], + " ", + [pending_xref, "None"])])])]) + + def test_optional_pyfunction_signature(app): text = ".. py:function:: compile(source [, filename [, symbol]]) -> ast object" doctree = restructuredtext.parse(app, text) @@ -498,6 +512,20 @@ def test_pydata_signature_old(app): domain="py", objtype="data", noindex=False) +def test_pydata_with_union_type_operator(app): + text = (".. py:data:: version\n" + " :type: int | str") + doctree = restructuredtext.parse(app, text) + assert_node(doctree[1][0], + ([desc_name, "version"], + [desc_annotation, (": ", + [pending_xref, "int"], + " ", + [desc_sig_punctuation, "|"], + " ", + [pending_xref, "str"])])) + + def test_pyobject_prefix(app): text = (".. py:class:: Foo\n" "\n" |