summaryrefslogtreecommitdiff
path: root/tests/test_apidoc.py
diff options
context:
space:
mode:
authorArcadiy Ivanov <arcadiy@ivanov.biz>2016-09-12 18:17:03 -0400
committerArcadiy Ivanov <arcadiy@ivanov.biz>2016-09-15 11:49:34 -0400
commite34b6823c7b51d5d0f424e00bca012076d802a14 (patch)
tree24b8f9cdfae2a72e1109eb30e15565756895c1e6 /tests/test_apidoc.py
parentc832d36d19ba13e0009f28f54749a9be690f6500 (diff)
downloadsphinx-git-e34b6823c7b51d5d0f424e00bca012076d802a14.tar.gz
Sphinx apidoc does not process PEP-0420 implicit namespaces
fixes #2949, connected to #2949
Diffstat (limited to 'tests/test_apidoc.py')
-rw-r--r--tests/test_apidoc.py88
1 files changed, 88 insertions, 0 deletions
diff --git a/tests/test_apidoc.py b/tests/test_apidoc.py
index 596890041..ff6a147ca 100644
--- a/tests/test_apidoc.py
+++ b/tests/test_apidoc.py
@@ -44,6 +44,94 @@ def test_simple(tempdir):
@with_tempdir
+def test_pep_0420_enabled(tempdir):
+ codedir = rootdir / 'root' / 'pep_0420'
+ outdir = tempdir / 'out'
+ args = ['sphinx-apidoc', '-o', outdir, '-F', codedir, "--implicit-namespaces"]
+ apidoc.main(args)
+
+ assert (outdir / 'conf.py').isfile()
+ assert (outdir / 'a.b.c.rst').isfile()
+ assert (outdir / 'a.b.x.rst').isfile()
+
+ with open(outdir / 'a.b.c.rst') as f:
+ rst = f.read()
+ assert "a.b.c package\n" in rst
+ assert "automodule:: a.b.c.d\n" in rst
+ assert "automodule:: a.b.c\n" in rst
+
+ with open(outdir / 'a.b.x.rst') as f:
+ rst = f.read()
+ assert "a.b.x namespace\n" in rst
+ assert "automodule:: a.b.x.y\n" in rst
+ assert "automodule:: a.b.x\n" not in rst
+
+ @with_app('text', srcdir=outdir)
+ def assert_build(app, status, warning):
+ app.build()
+ print(status.getvalue())
+ print(warning.getvalue())
+
+ sys.path.append(codedir)
+ try:
+ assert_build()
+ finally:
+ sys.path.remove(codedir)
+
+
+@with_tempdir
+def test_pep_0420_disabled(tempdir):
+ codedir = rootdir / 'root' / 'pep_0420'
+ outdir = tempdir / 'out'
+ args = ['sphinx-apidoc', '-o', outdir, '-F', codedir]
+ apidoc.main(args)
+
+ assert (outdir / 'conf.py').isfile()
+ assert not (outdir / 'a.b.c.rst').exists()
+ assert not (outdir / 'a.b.x.rst').exists()
+
+ @with_app('text', srcdir=outdir)
+ def assert_build(app, status, warning):
+ app.build()
+ print(status.getvalue())
+ print(warning.getvalue())
+
+ sys.path.append(codedir)
+ try:
+ assert_build()
+ finally:
+ sys.path.remove(codedir)
+
+@with_tempdir
+def test_pep_0420_disabled_top_level_verify(tempdir):
+ codedir = rootdir / 'root' / 'pep_0420' / 'a' / 'b'
+ outdir = tempdir / 'out'
+ args = ['sphinx-apidoc', '-o', outdir, '-F', codedir]
+ apidoc.main(args)
+
+ assert (outdir / 'conf.py').isfile()
+ assert (outdir / 'c.rst').isfile()
+ assert not (outdir / 'x.rst').exists()
+
+ with open(outdir / 'c.rst') as f:
+ rst = f.read()
+ assert "c package\n" in rst
+ assert "automodule:: c.d\n" in rst
+ assert "automodule:: c\n" in rst
+
+ @with_app('text', srcdir=outdir)
+ def assert_build(app, status, warning):
+ app.build()
+ print(status.getvalue())
+ print(warning.getvalue())
+
+ sys.path.append(codedir)
+ try:
+ assert_build()
+ finally:
+ sys.path.remove(codedir)
+
+@with_tempdir
def test_multibyte_parameters(tempdir):
codedir = rootdir / 'root'
outdir = tempdir / 'out'