2014-08-04 10:18:54 -05:00
|
|
|
"""
|
|
|
|
test_api_translator
|
|
|
|
~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Test the Sphinx API for translator.
|
|
|
|
|
2019-01-02 01:00:30 -06:00
|
|
|
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
2014-08-04 10:18:54 -05:00
|
|
|
:license: BSD, see LICENSE for details.
|
|
|
|
"""
|
2014-08-04 11:54:56 -05:00
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
import sys
|
2014-08-04 10:18:54 -05:00
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
import pytest
|
2014-08-04 10:18:54 -05:00
|
|
|
|
|
|
|
|
2017-05-07 02:46:44 -05:00
|
|
|
@pytest.fixture(scope='module', autouse=True)
|
|
|
|
def setup_module(rootdir):
|
|
|
|
p = rootdir / 'test-api-set-translator'
|
|
|
|
sys.path.insert(0, p)
|
|
|
|
yield
|
|
|
|
sys.path.remove(p)
|
2014-08-04 11:54:56 -05:00
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx('html')
|
2014-09-21 10:17:02 -05:00
|
|
|
def test_html_translator(app, status, warning):
|
2017-01-01 07:58:14 -06:00
|
|
|
# no set_translator()
|
2017-03-11 22:42:12 -06:00
|
|
|
translator_class = app.builder.get_translator_class()
|
2014-08-04 10:18:54 -05:00
|
|
|
assert translator_class
|
|
|
|
assert translator_class.__name__ == 'HTMLTranslator'
|
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx('html', testroot='api-set-translator')
|
2014-09-21 10:17:02 -05:00
|
|
|
def test_html_with_set_translator_for_html_(app, status, warning):
|
2017-01-01 07:58:14 -06:00
|
|
|
# use set_translator()
|
2017-03-11 22:42:12 -06:00
|
|
|
translator_class = app.builder.get_translator_class()
|
2014-08-04 10:18:54 -05:00
|
|
|
assert translator_class
|
|
|
|
assert translator_class.__name__ == 'ConfHTMLTranslator'
|
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx('singlehtml', testroot='api-set-translator')
|
2014-09-21 10:17:02 -05:00
|
|
|
def test_singlehtml_set_translator_for_singlehtml(app, status, warning):
|
2017-03-11 22:42:12 -06:00
|
|
|
translator_class = app.builder.get_translator_class()
|
2014-08-04 10:18:54 -05:00
|
|
|
assert translator_class
|
|
|
|
assert translator_class.__name__ == 'ConfSingleHTMLTranslator'
|
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx('pickle', testroot='api-set-translator')
|
2014-09-21 10:17:02 -05:00
|
|
|
def test_pickle_set_translator_for_pickle(app, status, warning):
|
2017-03-11 22:42:12 -06:00
|
|
|
translator_class = app.builder.get_translator_class()
|
2014-08-04 10:18:54 -05:00
|
|
|
assert translator_class
|
|
|
|
assert translator_class.__name__ == 'ConfPickleTranslator'
|
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx('json', testroot='api-set-translator')
|
2014-09-21 10:17:02 -05:00
|
|
|
def test_json_set_translator_for_json(app, status, warning):
|
2017-03-11 22:42:12 -06:00
|
|
|
translator_class = app.builder.get_translator_class()
|
2014-08-04 10:18:54 -05:00
|
|
|
assert translator_class
|
|
|
|
assert translator_class.__name__ == 'ConfJsonTranslator'
|
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx('latex', testroot='api-set-translator')
|
2014-09-21 10:17:02 -05:00
|
|
|
def test_html_with_set_translator_for_latex(app, status, warning):
|
2017-03-11 22:42:12 -06:00
|
|
|
translator_class = app.builder.get_translator_class()
|
2014-08-04 10:18:54 -05:00
|
|
|
assert translator_class
|
|
|
|
assert translator_class.__name__ == 'ConfLaTeXTranslator'
|
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx('man', testroot='api-set-translator')
|
2014-09-21 10:17:02 -05:00
|
|
|
def test_html_with_set_translator_for_man(app, status, warning):
|
2017-03-11 22:42:12 -06:00
|
|
|
translator_class = app.builder.get_translator_class()
|
2014-08-04 10:18:54 -05:00
|
|
|
assert translator_class
|
|
|
|
assert translator_class.__name__ == 'ConfManualPageTranslator'
|
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx('texinfo', testroot='api-set-translator')
|
2014-09-21 10:17:02 -05:00
|
|
|
def test_html_with_set_translator_for_texinfo(app, status, warning):
|
2017-03-11 22:42:12 -06:00
|
|
|
translator_class = app.builder.get_translator_class()
|
2014-08-04 10:18:54 -05:00
|
|
|
assert translator_class
|
|
|
|
assert translator_class.__name__ == 'ConfTexinfoTranslator'
|
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx('text', testroot='api-set-translator')
|
2014-09-21 10:17:02 -05:00
|
|
|
def test_html_with_set_translator_for_text(app, status, warning):
|
2017-03-11 22:42:12 -06:00
|
|
|
translator_class = app.builder.get_translator_class()
|
2014-08-04 10:18:54 -05:00
|
|
|
assert translator_class
|
|
|
|
assert translator_class.__name__ == 'ConfTextTranslator'
|
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx('xml', testroot='api-set-translator')
|
2014-09-21 10:17:02 -05:00
|
|
|
def test_html_with_set_translator_for_xml(app, status, warning):
|
2017-03-11 22:42:12 -06:00
|
|
|
translator_class = app.builder.get_translator_class()
|
2014-08-04 10:18:54 -05:00
|
|
|
assert translator_class
|
|
|
|
assert translator_class.__name__ == 'ConfXMLTranslator'
|
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx('pseudoxml', testroot='api-set-translator')
|
2014-09-21 10:17:02 -05:00
|
|
|
def test_html_with_set_translator_for_pseudoxml(app, status, warning):
|
2017-03-11 22:42:12 -06:00
|
|
|
translator_class = app.builder.get_translator_class()
|
2014-08-04 10:18:54 -05:00
|
|
|
assert translator_class
|
|
|
|
assert translator_class.__name__ == 'ConfPseudoXMLTranslator'
|