summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/root/pep_0420/a/b/c/__init__.py1
-rw-r--r--tests/root/pep_0420/a/b/c/d.py1
-rw-r--r--tests/root/pep_0420/a/b/x/y.py1
-rw-r--r--tests/test_apidoc.py88
4 files changed, 91 insertions, 0 deletions
diff --git a/tests/root/pep_0420/a/b/c/__init__.py b/tests/root/pep_0420/a/b/c/__init__.py
new file mode 100644
index 000000000..619273942
--- /dev/null
+++ b/tests/root/pep_0420/a/b/c/__init__.py
@@ -0,0 +1 @@
+"Package C" \ No newline at end of file
diff --git a/tests/root/pep_0420/a/b/c/d.py b/tests/root/pep_0420/a/b/c/d.py
new file mode 100644
index 000000000..6b0b45d90
--- /dev/null
+++ b/tests/root/pep_0420/a/b/c/d.py
@@ -0,0 +1 @@
+"Module d" \ No newline at end of file
diff --git a/tests/root/pep_0420/a/b/x/y.py b/tests/root/pep_0420/a/b/x/y.py
new file mode 100644
index 000000000..8b49b2079
--- /dev/null
+++ b/tests/root/pep_0420/a/b/x/y.py
@@ -0,0 +1 @@
+"Module y" \ No newline at end of file
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'