Test whether the escaping is correct by looking at the plaintext

Otherwise we're just testing that the headers are produced with format_header
This commit is contained in:
Eric Wieser 2017-03-24 09:53:01 +00:00
parent 18d2e2e48b
commit a7397a21fe

View File

@ -19,8 +19,6 @@ from sphinx.apidoc import main as apidoc_main
from util import rootdir, remove_unicode_literals
from sphinx.util.rst import escape as rst_escape
@pytest.fixture()
def apidoc(tempdir, apidoc_params):
@ -73,13 +71,11 @@ def test_pep_0420_enabled(make_app, apidoc):
with open(outdir / 'a.b.c.rst') as f:
rst = f.read()
assert rst_escape("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 rst_escape("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
@ -88,6 +84,18 @@ def test_pep_0420_enabled(make_app, apidoc):
print(app._status.getvalue())
print(app._warning.getvalue())
builddir = outdir / '_build' / 'text'
assert (builddir / 'a.b.c.txt').isfile()
assert (builddir / 'a.b.x.txt').isfile()
with open(builddir / 'a.b.c.txt') as f:
txt = f.read()
assert "a.b.c package\n" in txt
with open(builddir / 'a.b.x.txt') as f:
txt = f.read()
assert "a.b.x namespace\n" in txt
@pytest.mark.apidoc(coderoot=(rootdir / 'roots' / 'test-apidoc-pep420'))
def test_pep_0420_disabled(make_app, apidoc):
@ -127,10 +135,17 @@ def test_trailing_underscore(make_app, apidoc):
outdir = apidoc.outdir
assert (outdir / 'conf.py').isfile()
assert (outdir / 'package_.rst').isfile()
with open(outdir / 'package_.rst') as f:
app = make_app('text', srcdir=outdir)
app.build()
print(app._status.getvalue())
print(app._warning.getvalue())
builddir = outdir / '_build' / 'text'
with open(builddir / 'package_.txt') as f:
rst = f.read()
assert rst_escape("package_ package\n") in rst
assert rst_escape("package_.module_ module\n") in rst
assert "package_ package\n" in rst
assert "package_.module_ module\n" in rst
@pytest.mark.apidoc(
coderoot=(rootdir / 'root'),