mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-10-12 16:32:10 -05:00
refactor tests for autosectionlabel
This commit is contained in:
1 parent
2d44232e34
commit
ac399b3b4e
3 files changed
+34
-17
No files matched your search
@@ -15,6 +15,12 @@ For Windows users
|
|||||||
For UNIX users
|
For UNIX users
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
Linux
|
||||||
|
^^^^^
|
||||||
|
|
||||||
|
FreeBSD
|
||||||
|
^^^^^^^
|
||||||
|
|
||||||
This one's got an apostrophe
|
This one's got an apostrophe
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
@@ -26,4 +32,6 @@ References
|
|||||||
* :ref:`index:Installation`
|
* :ref:`index:Installation`
|
||||||
* :ref:`index:For Windows users`
|
* :ref:`index:For Windows users`
|
||||||
* :ref:`index:For UNIX users`
|
* :ref:`index:For UNIX users`
|
||||||
|
* :ref:`index:Linux`
|
||||||
|
* :ref:`index:FreeBSD`
|
||||||
* :ref:`index:This one's got an apostrophe`
|
* :ref:`index:This one's got an apostrophe`
|
||||||
@@ -27,6 +27,7 @@ This one's got an apostrophe
|
|||||||
References
|
References
|
||||||
==========
|
==========
|
||||||
|
|
||||||
|
* :ref:`test-ext-autosectionlabel`
|
||||||
* :ref:`Introduce of Sphinx`
|
* :ref:`Introduce of Sphinx`
|
||||||
* :ref:`Installation`
|
* :ref:`Installation`
|
||||||
* :ref:`For Windows users`
|
* :ref:`For Windows users`
|
||||||
|
|||||||
@@ -34,10 +34,6 @@ def test_autosectionlabel_html(app, status, warning, skipped_labels=False):
|
|||||||
'<span class="std std-ref">For UNIX users</span></a></li>')
|
'<span class="std std-ref">For UNIX users</span></a></li>')
|
||||||
assert re.search(html, content, re.S)
|
assert re.search(html, content, re.S)
|
||||||
|
|
||||||
if skipped_labels is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
if not skipped_labels:
|
|
||||||
html = ('<li><a class="reference internal" href="#linux">'
|
html = ('<li><a class="reference internal" href="#linux">'
|
||||||
'<span class="std std-ref">Linux</span></a></li>')
|
'<span class="std std-ref">Linux</span></a></li>')
|
||||||
assert re.search(html, content, re.S)
|
assert re.search(html, content, re.S)
|
||||||
@@ -45,15 +41,6 @@ def test_autosectionlabel_html(app, status, warning, skipped_labels=False):
|
|||||||
html = ('<li><a class="reference internal" href="#freebsd">'
|
html = ('<li><a class="reference internal" href="#freebsd">'
|
||||||
'<span class="std std-ref">FreeBSD</span></a></li>')
|
'<span class="std std-ref">FreeBSD</span></a></li>')
|
||||||
assert re.search(html, content, re.S)
|
assert re.search(html, content, re.S)
|
||||||
else:
|
|
||||||
html = '<li><span class="xref std std-ref">Linux</span></li>'
|
|
||||||
assert re.search(html, content, re.S)
|
|
||||||
|
|
||||||
html = '<li><span class="xref std std-ref">FreeBSD</span></li>'
|
|
||||||
assert re.search(html, content, re.S)
|
|
||||||
|
|
||||||
assert 'WARNING: undefined label: linux' in warning.getvalue()
|
|
||||||
assert 'WARNING: undefined label: freebsd' in warning.getvalue()
|
|
||||||
|
|
||||||
# for smart_quotes (refs: #4027)
|
# for smart_quotes (refs: #4027)
|
||||||
html = ('<li><a class="reference internal" '
|
html = ('<li><a class="reference internal" '
|
||||||
@@ -66,12 +53,33 @@ def test_autosectionlabel_html(app, status, warning, skipped_labels=False):
|
|||||||
# Re-use test definition from above, just change the test root directory
|
# Re-use test definition from above, just change the test root directory
|
||||||
@pytest.mark.sphinx('html', testroot='ext-autosectionlabel-prefix-document')
|
@pytest.mark.sphinx('html', testroot='ext-autosectionlabel-prefix-document')
|
||||||
def test_autosectionlabel_prefix_document_html(app, status, warning):
|
def test_autosectionlabel_prefix_document_html(app, status, warning):
|
||||||
return test_autosectionlabel_html(app, status, warning,
|
test_autosectionlabel_html(app, status, warning)
|
||||||
skipped_labels=None)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx('html', testroot='ext-autosectionlabel',
|
@pytest.mark.sphinx('html', testroot='ext-autosectionlabel',
|
||||||
confoverrides={'autosectionlabel_maxdepth': 3})
|
confoverrides={'autosectionlabel_maxdepth': 3})
|
||||||
def test_autosectionlabel_maxdepth(app, status, warning):
|
def test_autosectionlabel_maxdepth(app, status, warning):
|
||||||
return test_autosectionlabel_html(app, status, warning,
|
app.builder.build_all()
|
||||||
skipped_labels=True)
|
|
||||||
|
content = (app.outdir / 'index.html').text()
|
||||||
|
|
||||||
|
# depth: 1
|
||||||
|
html = ('<li><a class="reference internal" href="#test-ext-autosectionlabel">'
|
||||||
|
'<span class=".*?">test-ext-autosectionlabel</span></a></li>')
|
||||||
|
assert re.search(html, content, re.S)
|
||||||
|
|
||||||
|
# depth: 2
|
||||||
|
html = ('<li><a class="reference internal" href="#installation">'
|
||||||
|
'<span class="std std-ref">Installation</span></a></li>')
|
||||||
|
assert re.search(html, content, re.S)
|
||||||
|
|
||||||
|
# depth: 3
|
||||||
|
html = ('<li><a class="reference internal" href="#for-windows-users">'
|
||||||
|
'<span class="std std-ref">For Windows users</span></a></li>')
|
||||||
|
assert re.search(html, content, re.S)
|
||||||
|
|
||||||
|
# depth: 4
|
||||||
|
html = '<li><span class="xref std std-ref">Linux</span></li>'
|
||||||
|
assert re.search(html, content, re.S)
|
||||||
|
|
||||||
|
assert 'WARNING: undefined label: linux' in warning.getvalue()
|
||||||
Reference in new issue
Block a user