summaryrefslogtreecommitdiff
path: root/tests/test_util_typing.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2021-09-21 02:03:31 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2021-09-21 02:03:31 +0900
commite79efef63a7e748cc96c95a592a59a2a16704bf1 (patch)
tree64dff9cb895de6f7af5bb3ec2633660a8b63716b /tests/test_util_typing.py
parenta05dc0b41992b92fc4e352439a27eddd0f5a88a9 (diff)
downloadsphinx-git-e79efef63a7e748cc96c95a592a59a2a16704bf1.tar.gz
Fix #9657: autodoc: basecls for a subclass of mocked object is incorrect
Diffstat (limited to 'tests/test_util_typing.py')
-rw-r--r--tests/test_util_typing.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/test_util_typing.py b/tests/test_util_typing.py
index ad57a347e..d65b9cdc5 100644
--- a/tests/test_util_typing.py
+++ b/tests/test_util_typing.py
@@ -17,6 +17,7 @@ from typing import (Any, Callable, Dict, Generator, List, NewType, Optional, Tup
import pytest
+from sphinx.ext.autodoc import mock
from sphinx.util.typing import restify, stringify
@@ -169,6 +170,12 @@ def test_restify_broken_type_hints():
assert restify(BrokenType) == ':py:class:`tests.test_util_typing.BrokenType`'
+def test_restify_mock():
+ with mock(['unknown']):
+ import unknown
+ assert restify(unknown.secret.Class) == ':py:class:`unknown.secret.Class`'
+
+
def test_stringify():
assert stringify(int) == "int"
assert stringify(str) == "str"
@@ -293,3 +300,9 @@ def test_stringify_type_union_operator():
def test_stringify_broken_type_hints():
assert stringify(BrokenType) == 'tests.test_util_typing.BrokenType'
+
+
+def test_stringify_mock():
+ with mock(['unknown']):
+ import unknown
+ assert stringify(unknown.secret.Class) == 'unknown.secret.Class'