2014-08-04 10:18:54 -05:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
test_api_translator
|
|
|
|
~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Test the Sphinx API for translator.
|
|
|
|
|
2016-01-14 15:54:04 -06:00
|
|
|
:copyright: Copyright 2007-2016 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
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
from util import with_app, rootdir
|
2014-08-04 10:18:54 -05:00
|
|
|
|
|
|
|
|
2014-08-04 11:54:56 -05:00
|
|
|
def setup_module():
|
2014-09-21 10:17:02 -05:00
|
|
|
sys.path.insert(0, rootdir / 'roots' / 'test-api-set-translator')
|
2014-08-04 11:54:56 -05:00
|
|
|
|
|
|
|
|
|
|
|
def teardown_module():
|
2014-09-21 10:17:02 -05:00
|
|
|
sys.path.remove(rootdir / 'roots' / 'test-api-set-translator')
|
2014-08-04 11:54:56 -05:00
|
|
|
|
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
@with_app('html')
|
|
|
|
def test_html_translator(app, status, warning):
|
2014-08-04 10:18:54 -05:00
|
|
|
# no set_translator(), no html_translator_class
|
|
|
|
translator_class = app.builder.translator_class
|
|
|
|
assert translator_class
|
|
|
|
assert translator_class.__name__ == 'SmartyPantsHTMLTranslator'
|
|
|
|
|
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
@with_app('html', confoverrides={
|
|
|
|
'html_translator_class': 'translator.ExtHTMLTranslator'})
|
|
|
|
def test_html_with_html_translator_class(app, status, warning):
|
2014-08-04 10:18:54 -05:00
|
|
|
# no set_translator(), but html_translator_class
|
|
|
|
translator_class = app.builder.translator_class
|
|
|
|
assert translator_class
|
|
|
|
assert translator_class.__name__ == 'ExtHTMLTranslator'
|
|
|
|
|
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
@with_app('html',
|
|
|
|
confoverrides={'html_use_smartypants': False})
|
|
|
|
def test_html_with_smartypants(app, status, warning):
|
2014-08-04 10:18:54 -05:00
|
|
|
# no set_translator(), html_use_smartypants=False
|
|
|
|
translator_class = app.builder.translator_class
|
|
|
|
assert translator_class
|
|
|
|
assert translator_class.__name__ == 'HTMLTranslator'
|
|
|
|
|
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
@with_app('html', testroot='api-set-translator')
|
|
|
|
def test_html_with_set_translator_for_html_(app, status, warning):
|
2014-08-04 10:18:54 -05:00
|
|
|
# use set_translator(), no html_translator_class
|
|
|
|
translator_class = app.builder.translator_class
|
|
|
|
assert translator_class
|
|
|
|
assert translator_class.__name__ == 'ConfHTMLTranslator'
|
|
|
|
|
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
@with_app('html', testroot='api-set-translator',
|
|
|
|
confoverrides={'html_translator_class': 'ext.ExtHTMLTranslator'})
|
2014-10-09 09:53:33 -05:00
|
|
|
def test_html_with_set_translator_for_html_and_html_translator_class(
|
|
|
|
app, status, warning):
|
2014-08-04 10:18:54 -05:00
|
|
|
# use set_translator() and html_translator_class.
|
|
|
|
# set_translator() is given priority over html_translator_clas.
|
|
|
|
translator_class = app.builder.translator_class
|
|
|
|
assert translator_class
|
|
|
|
assert translator_class.__name__ == 'ConfHTMLTranslator'
|
|
|
|
|
|
|
|
|
2014-08-04 11:54:56 -05:00
|
|
|
## this test break test_websupport.test_comments test. why?
|
|
|
|
# @with_app(
|
|
|
|
# buildername='dirhtml',
|
|
|
|
# srcdir=(test_roots / 'test-api-set-translator'),
|
|
|
|
# )
|
2014-09-21 10:17:02 -05:00
|
|
|
# def test_dirhtml_set_translator_for_dirhtml(app, status, warning):
|
2014-08-04 11:54:56 -05:00
|
|
|
# translator_class = app.builder.translator_class
|
|
|
|
# assert translator_class
|
|
|
|
# assert translator_class.__name__ == 'ConfDirHTMLTranslator'
|
2014-08-04 10:18:54 -05:00
|
|
|
|
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
@with_app('singlehtml', testroot='api-set-translator')
|
|
|
|
def test_singlehtml_set_translator_for_singlehtml(app, status, warning):
|
2014-08-04 10:18:54 -05:00
|
|
|
translator_class = app.builder.translator_class
|
|
|
|
assert translator_class
|
|
|
|
assert translator_class.__name__ == 'ConfSingleHTMLTranslator'
|
|
|
|
|
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
@with_app('pickle', testroot='api-set-translator')
|
|
|
|
def test_pickle_set_translator_for_pickle(app, status, warning):
|
2014-08-04 10:18:54 -05:00
|
|
|
translator_class = app.builder.translator_class
|
|
|
|
assert translator_class
|
|
|
|
assert translator_class.__name__ == 'ConfPickleTranslator'
|
|
|
|
|
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
@with_app('json', testroot='api-set-translator')
|
|
|
|
def test_json_set_translator_for_json(app, status, warning):
|
2014-08-04 10:18:54 -05:00
|
|
|
translator_class = app.builder.translator_class
|
|
|
|
assert translator_class
|
|
|
|
assert translator_class.__name__ == 'ConfJsonTranslator'
|
|
|
|
|
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
@with_app('latex', testroot='api-set-translator')
|
|
|
|
def test_html_with_set_translator_for_latex(app, status, warning):
|
2014-08-04 10:18:54 -05:00
|
|
|
translator_class = app.builder.translator_class
|
|
|
|
assert translator_class
|
|
|
|
assert translator_class.__name__ == 'ConfLaTeXTranslator'
|
|
|
|
|
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
@with_app('man', testroot='api-set-translator')
|
|
|
|
def test_html_with_set_translator_for_man(app, status, warning):
|
2014-08-04 10:18:54 -05:00
|
|
|
translator_class = app.builder.translator_class
|
|
|
|
assert translator_class
|
|
|
|
assert translator_class.__name__ == 'ConfManualPageTranslator'
|
|
|
|
|
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
@with_app('texinfo', testroot='api-set-translator')
|
|
|
|
def test_html_with_set_translator_for_texinfo(app, status, warning):
|
2014-08-04 10:18:54 -05:00
|
|
|
translator_class = app.builder.translator_class
|
|
|
|
assert translator_class
|
|
|
|
assert translator_class.__name__ == 'ConfTexinfoTranslator'
|
|
|
|
|
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
@with_app('text', testroot='api-set-translator')
|
|
|
|
def test_html_with_set_translator_for_text(app, status, warning):
|
2014-08-04 10:18:54 -05:00
|
|
|
translator_class = app.builder.translator_class
|
|
|
|
assert translator_class
|
|
|
|
assert translator_class.__name__ == 'ConfTextTranslator'
|
|
|
|
|
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
@with_app('xml', testroot='api-set-translator')
|
|
|
|
def test_html_with_set_translator_for_xml(app, status, warning):
|
2014-08-04 10:18:54 -05:00
|
|
|
translator_class = app.builder.translator_class
|
|
|
|
assert translator_class
|
|
|
|
assert translator_class.__name__ == 'ConfXMLTranslator'
|
|
|
|
|
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
@with_app('pseudoxml', testroot='api-set-translator')
|
|
|
|
def test_html_with_set_translator_for_pseudoxml(app, status, warning):
|
2014-08-04 10:18:54 -05:00
|
|
|
translator_class = app.builder.translator_class
|
|
|
|
assert translator_class
|
|
|
|
assert translator_class.__name__ == 'ConfPseudoXMLTranslator'
|