2016-02-14 01:07:32 -06:00
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
"""
|
|
|
|
|
test_ext_autosectionlabel
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
Test sphinx.ext.autosectionlabel extension.
|
|
|
|
|
|
2017-12-31 10:06:58 -06:00
|
|
|
|
:copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
|
2016-02-14 01:07:32 -06:00
|
|
|
|
:license: BSD, see LICENSE for details.
|
|
|
|
|
"""
|
|
|
|
|
|
2017-09-06 17:33:12 -05:00
|
|
|
|
import os
|
2016-02-14 01:07:32 -06:00
|
|
|
|
import re
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
|
import pytest
|
2016-02-14 01:07:32 -06:00
|
|
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
|
@pytest.mark.sphinx('html', testroot='ext-autosectionlabel')
|
2016-02-14 01:07:32 -06:00
|
|
|
|
def test_autosectionlabel_html(app, status, warning):
|
|
|
|
|
app.builder.build_all()
|
|
|
|
|
|
|
|
|
|
content = (app.outdir / 'index.html').text()
|
|
|
|
|
html = ('<li><a class="reference internal" href="#introduce-of-sphinx">'
|
|
|
|
|
'<span class=".*?">Introduce of Sphinx</span></a></li>')
|
|
|
|
|
assert re.search(html, content, re.S)
|
|
|
|
|
|
|
|
|
|
html = ('<li><a class="reference internal" href="#installation">'
|
|
|
|
|
'<span class="std std-ref">Installation</span></a></li>')
|
|
|
|
|
assert re.search(html, content, re.S)
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
html = ('<li><a class="reference internal" href="#for-unix-users">'
|
|
|
|
|
'<span class="std std-ref">For UNIX users</span></a></li>')
|
|
|
|
|
assert re.search(html, content, re.S)
|
2017-02-03 18:23:16 -06:00
|
|
|
|
|
2017-09-06 17:33:12 -05:00
|
|
|
|
|
|
|
|
|
@pytest.mark.skipif(
|
|
|
|
|
os.environ.get('DOCUTILS', None) not in ('0.13.1', '0.14'),
|
|
|
|
|
reason='Requires docutils >= 0.13.1',
|
|
|
|
|
)
|
|
|
|
|
@pytest.mark.sphinx('html', testroot='ext-autosectionlabel')
|
|
|
|
|
def test_autosectionlabel_html_apostrophe(app, status, warning):
|
|
|
|
|
app.builder.build_all()
|
|
|
|
|
|
|
|
|
|
content = (app.outdir / 'index.html').text()
|
2017-09-05 22:56:11 -05:00
|
|
|
|
html = ('<li><a class="reference internal" '
|
|
|
|
|
'href="#this-one-s-got-an-apostrophe">'
|
|
|
|
|
'<span class="std std-ref">This one’s got an apostrophe'
|
|
|
|
|
'</span></a></li>')
|
|
|
|
|
assert re.search(html, content, re.S)
|
|
|
|
|
|
2017-02-03 18:23:16 -06:00
|
|
|
|
|
|
|
|
|
# Re-use test definition from above, just change the test root directory
|
|
|
|
|
@pytest.mark.sphinx('html', testroot='ext-autosectionlabel-prefix-document')
|
|
|
|
|
def test_autosectionlabel_prefix_document_html(app, status, warning):
|
|
|
|
|
return test_autosectionlabel_html(app, status, warning)
|
2017-09-06 17:33:12 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Re-use test definition from above, just change the test root directory
|
|
|
|
|
@pytest.mark.skipif(
|
|
|
|
|
os.environ.get('DOCUTILS', None) not in ('0.13.1', '0.14'),
|
|
|
|
|
reason='Requires docutils >= 0.13.1',
|
|
|
|
|
)
|
|
|
|
|
@pytest.mark.sphinx('html', testroot='ext-autosectionlabel-prefix-document')
|
|
|
|
|
def test_autosectionlabel_prefix_document_html_apostrophe(app, status, warning):
|
|
|
|
|
return test_autosectionlabel_html_apostrophe(app, status, warning)
|