2022-02-19 21:05:56 -06:00
|
|
|
"""Tests the post_transforms"""
|
2021-05-17 11:09:42 -05:00
|
|
|
|
|
|
|
import pytest
|
|
|
|
from docutils import nodes
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx('html', testroot='transforms-post_transforms-missing-reference')
|
|
|
|
def test_nitpicky_warning(app, status, warning):
|
|
|
|
app.build()
|
|
|
|
assert ('index.rst:4: WARNING: py:class reference target '
|
|
|
|
'not found: io.StringIO' in warning.getvalue())
|
|
|
|
|
2022-04-26 21:04:19 -05:00
|
|
|
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
2021-05-17 11:09:42 -05:00
|
|
|
assert ('<p><code class="xref py py-class docutils literal notranslate"><span class="pre">'
|
|
|
|
'io.StringIO</span></code></p>' in content)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx('html', testroot='transforms-post_transforms-missing-reference',
|
|
|
|
freshenv=True)
|
|
|
|
def test_missing_reference(app, status, warning):
|
|
|
|
def missing_reference(app, env, node, contnode):
|
|
|
|
assert app is app
|
|
|
|
assert env is app.env
|
|
|
|
assert node['reftarget'] == 'io.StringIO'
|
|
|
|
assert contnode.astext() == 'io.StringIO'
|
|
|
|
|
|
|
|
return nodes.inline('', 'missing-reference.StringIO')
|
|
|
|
|
|
|
|
warning.truncate(0)
|
|
|
|
app.connect('missing-reference', missing_reference)
|
|
|
|
app.build()
|
|
|
|
assert warning.getvalue() == ''
|
|
|
|
|
2022-04-26 21:04:19 -05:00
|
|
|
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
2021-05-17 11:09:42 -05:00
|
|
|
assert '<p><span>missing-reference.StringIO</span></p>' in content
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx('html', testroot='domain-py-python_use_unqualified_type_names',
|
|
|
|
freshenv=True)
|
|
|
|
def test_missing_reference_conditional_pending_xref(app, status, warning):
|
|
|
|
def missing_reference(app, env, node, contnode):
|
|
|
|
return contnode
|
|
|
|
|
|
|
|
warning.truncate(0)
|
|
|
|
app.connect('missing-reference', missing_reference)
|
|
|
|
app.build()
|
|
|
|
assert warning.getvalue() == ''
|
|
|
|
|
2022-04-26 21:04:19 -05:00
|
|
|
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
2021-05-17 11:09:42 -05:00
|
|
|
assert '<span class="n"><span class="pre">Age</span></span>' in content
|
2022-05-31 18:35:28 -05:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx('html', testroot='transforms-post_transforms-keyboard',
|
|
|
|
freshenv=True)
|
2022-06-01 12:10:55 -05:00
|
|
|
def test_keyboard_hyphen_spaces(app):
|
2022-05-31 18:35:28 -05:00
|
|
|
"""Regression test for issue 10495, we want no crash."""
|
|
|
|
app.build()
|
2022-05-31 18:50:41 -05:00
|
|
|
assert "spanish" in (app.outdir / 'index.html').read_text(encoding='utf8')
|
|
|
|
assert "inquisition" in (app.outdir / 'index.html').read_text(encoding='utf8')
|