fix the tests by falling back to a empty dict on AttributeError

This commit is contained in:
Keewis 2020-08-04 20:48:59 +02:00
parent d9fb3bc25c
commit e697242451
2 changed files with 27 additions and 1 deletions

View File

@ -1131,7 +1131,11 @@ class NumpyDocstring(GoogleDocstring):
func_name1, func_name2, :meth:`func_name`, func_name3
"""
inventory = getattr(self._app.builder.env, "intersphinx_inventory", {})
try:
inventory = self._app.builder.env.intersphinx_inventory
except AttributeError:
inventory = {}
items = []
def parse_item_name(text: str) -> Tuple[str, str]:

View File

@ -1365,6 +1365,7 @@ otherfunc : relationship
config = Config()
app = mock.Mock()
app.builder.env = None
actual = str(NumpyDocstring(docstring, config, app, "method"))
expected = """\
@ -1379,6 +1380,27 @@ numpy.multivariate_normal(mean, cov, shape=None, spam=None)
"""
self.assertEqual(expected, actual)
config = Config()
app = mock.Mock()
app.builder.env.intersphinx_inventory = {
"py:func": {"funcs": (), "otherfunc": ()},
"py:meth": {"some": (), "other": ()},
}
actual = str(NumpyDocstring(docstring, config, app, "method"))
expected = """\
numpy.multivariate_normal(mean, cov, shape=None, spam=None)
.. seealso::
:meth:`some`, :meth:`other`, :func:`funcs`
\n\
:func:`otherfunc`
relationship
"""
self.assertEqual(expected, actual)
def test_colon_in_return_type(self):
docstring = """
Summary