From e3260fd47258e68298e61cd619603dc72d52ff9a Mon Sep 17 00:00:00 2001 From: Steph Prince <40640337+stephprince@users.noreply.github.com> Date: Wed, 17 Jan 2024 11:01:13 -0800 Subject: [PATCH] add test for docstring generation --- tests/unit/utils_test/test_docval.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/unit/utils_test/test_docval.py b/tests/unit/utils_test/test_docval.py index d0ea934f7..50c487182 100644 --- a/tests/unit/utils_test/test_docval.py +++ b/tests/unit/utils_test/test_docval.py @@ -827,6 +827,17 @@ def test_enum_forbidden_values(self): def method(self, **kwargs): pass + def test_nested_return_types(self): + """Test that having nested tuple rtype creates valid sphinx references""" + @docval({'name': 'arg1', 'type': int, 'doc': 'an arg'}, + returns='output', rtype=(list, (list, bool), (list, 'Test'))) + def method(self, **kwargs): + return [] + + doc = ('method(arg1)\n\n\n\nArgs:\n arg1 (:py:class:`~int`): an arg\n\nReturns:\n ' + ':py:class:`~list` or :py:class:`~list`, :py:class:`~bool` or :py:class:`~list`, Test: output') + self.assertEqual(method.__doc__, doc) + class TestDocValidatorChain(TestCase):