Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sphinx_click/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from sphinx import application
from sphinx.util import logging
from sphinx.util import nodes as sphinx_nodes
from sphinx.ext.autodoc import mock
from sphinx.ext.autodoc.mock import mock

LOG = logging.getLogger(__name__)

Expand Down
21 changes: 21 additions & 0 deletions tests/test_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@
from sphinx import addnodes as sphinx_nodes


def test_mock_import_compatibility():
"""Test that sphinx_click.ext.mock is callable after sphinx.ext.autodoc.mock is imported.

Regression test for https://github.com/click-contrib/sphinx-click/issues/159

When sphinx_autodoc_typehints imports `from sphinx.ext.autodoc.mock import mock`,
it causes Python to bind the submodule as an attribute on sphinx.ext.autodoc,
which can shadow the re-exported mock function. sphinx_click must import mock
directly from the submodule to avoid this issue.
"""
# Simulate sphinx_autodoc_typehints being loaded first
from sphinx.ext.autodoc.mock import mock # noqa: F401

# Now import sphinx_click (as would happen during Sphinx extension loading)
import sphinx_click.ext

# Verify the mock function is callable
with sphinx_click.ext.mock([]):
pass


def test_basics(make_app, rootdir):
srcdir = rootdir / 'basics'
app = make_app('xml', srcdir=srcdir)
Expand Down