From d7cab2ebfa768c7b04fbbf131c15462e3a3147ec Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Wed, 4 Mar 2020 00:53:48 +0900 Subject: [PATCH] test: Add testcase for special case of PythonDomain.find_obj() --- tests/roots/test-domain-py/module.rst | 8 ++++++++ tests/test_domain_py.py | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/tests/roots/test-domain-py/module.rst b/tests/roots/test-domain-py/module.rst index c01032b26..dce3fa5ac 100644 --- a/tests/roots/test-domain-py/module.rst +++ b/tests/roots/test-domain-py/module.rst @@ -51,3 +51,11 @@ module .. py:attribute:: attr2 :type: :doc:`index` + +.. py:module:: exceptions + +.. py:exception:: Exception + +.. py:module:: object + +.. py:function:: sum() diff --git a/tests/test_domain_py.py b/tests/test_domain_py.py index 218ded510..8d6d43b48 100644 --- a/tests/test_domain_py.py +++ b/tests/test_domain_py.py @@ -206,6 +206,18 @@ def test_domain_py_find_obj(app, status, warning): [('NestedParentA.NestedChildA.subchild_1', ('roles', 'nestedparenta-nestedchilda-subchild-1', 'method'))]) + # special case: exceptions + assert (find_obj('exceptions', None, 'Exception', 'exc') == + [('exceptions.Exception', ('module', 'exceptions-exception', 'exception'))]) + assert (find_obj(None, None, 'Exception', 'exc') == + [('exceptions.Exception', ('module', 'exceptions-exception', 'exception'))]) + + # special case: object + assert (find_obj('object', None, 'sum', 'func') == + [('object.sum', ('module', 'object-sum', 'function'))]) + assert (find_obj(None, None, 'sum', 'func') == + [('object.sum', ('module', 'object-sum', 'function'))]) + def test_get_full_qualified_name(): env = Mock(domaindata={})