# -*- coding: utf-8 -*-
"""
test_ext_autosectionlabel
~~~~~~~~~~~~~~~~~~~~~~~~~
Test sphinx.ext.autosectionlabel extension.
:copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
import os
import re
import pytest
@pytest.mark.sphinx('html', testroot='ext-autosectionlabel')
def test_autosectionlabel_html(app, status, warning):
app.builder.build_all()
content = (app.outdir / 'index.html').text()
html = ('
'
'Introduce of Sphinx')
assert re.search(html, content, re.S)
html = (''
'Installation')
assert re.search(html, content, re.S)
html = (''
'For Windows users')
assert re.search(html, content, re.S)
html = (''
'For UNIX users')
assert re.search(html, content, re.S)
@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()
html = (''
'This one’s got an apostrophe'
'')
assert re.search(html, content, re.S)
# 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)
# 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)