diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2017-03-23 00:21:04 +0000 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2017-03-23 12:40:14 +0000 |
commit | 3e7bee583604e3422c05f807a69d0a73afedfa59 (patch) | |
tree | c1382f471b2b2265ff3e225ccef55fe771d3aba2 /tests/test_apidoc.py | |
parent | 895014cd7168fdef9c3552c4a3bb818615a39fce (diff) | |
download | sphinx-git-3e7bee583604e3422c05f807a69d0a73afedfa59.tar.gz |
Fix issues with trailing underscores in heading names
Fixes #1451, using the approach in 8d96c90fc6ca7805ba7a8e8fd80cc74da7caf46c
Diffstat (limited to 'tests/test_apidoc.py')
-rw-r--r-- | tests/test_apidoc.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/test_apidoc.py b/tests/test_apidoc.py index d44868aeb..d161fcd05 100644 --- a/tests/test_apidoc.py +++ b/tests/test_apidoc.py @@ -19,6 +19,8 @@ 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): @@ -71,13 +73,13 @@ def test_pep_0420_enabled(make_app, apidoc): with open(outdir / 'a.b.c.rst') as f: rst = f.read() - assert "a.b.c package\n" in rst + 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 "a.b.x namespace\n" in rst + 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 @@ -118,6 +120,15 @@ def test_pep_0420_disabled_top_level_verify(make_app, apidoc): print(app._status.getvalue()) print(app._warning.getvalue()) +@pytest.mark.apidoc(coderoot=(rootdir / 'root' / 'trailing_underscore')) +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: + rst = f.read() + assert rst_escape("package_ package\n") in rst + assert rst_escape("package_.module_ module\n") in rst @pytest.mark.apidoc( coderoot=(rootdir / 'root'), |