summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2022-05-01 19:02:37 +0900
committerGitHub <noreply@github.com>2022-05-01 19:02:37 +0900
commit2f29f0a96e66656dc75fb93b1dfc8cab6e7b7e20 (patch)
tree036b66140cc9db0eea59442a7eb1fe3c92d252d5 /tests
parent8c7ba8aa0add77c7bebc7f31dc675e51fdb2fa98 (diff)
parentbde47ce67957638712b23b5d249c085376dbf453 (diff)
downloadsphinx-git-2f29f0a96e66656dc75fb93b1dfc8cab6e7b7e20.tar.gz
Merge pull request #10406 from AA-Turner/apidoc-duplicates
Ensure submodules are unique in `sphinx.ext.apidoc`
Diffstat (limited to 'tests')
-rw-r--r--tests/roots/test-apidoc-duplicates/fish_licence/halibut.cpython-38-x86_64-linux-gnu.so0
-rw-r--r--tests/roots/test-apidoc-duplicates/fish_licence/halibut.pyx0
-rw-r--r--tests/test_ext_apidoc.py29
3 files changed, 29 insertions, 0 deletions
diff --git a/tests/roots/test-apidoc-duplicates/fish_licence/halibut.cpython-38-x86_64-linux-gnu.so b/tests/roots/test-apidoc-duplicates/fish_licence/halibut.cpython-38-x86_64-linux-gnu.so
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/roots/test-apidoc-duplicates/fish_licence/halibut.cpython-38-x86_64-linux-gnu.so
diff --git a/tests/roots/test-apidoc-duplicates/fish_licence/halibut.pyx b/tests/roots/test-apidoc-duplicates/fish_licence/halibut.pyx
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/roots/test-apidoc-duplicates/fish_licence/halibut.pyx
diff --git a/tests/test_ext_apidoc.py b/tests/test_ext_apidoc.py
index 7aba847a3..8a3c499f3 100644
--- a/tests/test_ext_apidoc.py
+++ b/tests/test_ext_apidoc.py
@@ -4,6 +4,7 @@ from collections import namedtuple
import pytest
+import sphinx.ext.apidoc
from sphinx.ext.apidoc import main as apidoc_main
from sphinx.testing.path import path
@@ -639,3 +640,31 @@ def test_namespace_package_file(tempdir):
" :members:\n"
" :undoc-members:\n"
" :show-inheritance:\n")
+
+
+def test_no_duplicates(rootdir, tempdir):
+ """Make sure that a ".pyx" and ".so" don't cause duplicate listings.
+
+ We can't use pytest.mark.apidoc here as we use a different set of arguments
+ to apidoc_main
+ """
+
+ original_suffixes = sphinx.ext.apidoc.PY_SUFFIXES
+ try:
+ # Ensure test works on Windows
+ sphinx.ext.apidoc.PY_SUFFIXES += ('.so',)
+
+ package = rootdir / 'test-apidoc-duplicates' / 'fish_licence'
+ outdir = tempdir / 'out'
+ apidoc_main(['-o', outdir, "-T", package, "--implicit-namespaces"])
+
+ # Ensure the module has been documented
+ assert (outdir / 'fish_licence.rst').isfile()
+
+ # Ensure the submodule only appears once
+ text = (outdir / 'fish_licence.rst').read_text(encoding="utf-8")
+ count_submodules = text.count(r'fish\_licence.halibut module')
+ assert count_submodules == 1
+
+ finally:
+ sphinx.ext.apidoc.PY_SUFFIXES = original_suffixes