pytest: remove deprecated with_app decorator functions

This commit is contained in:
shimizukawa
2017-01-06 01:14:47 +09:00
parent b3c207dd49
commit baaef9146d
38 changed files with 264 additions and 246 deletions

View File

@@ -11,7 +11,8 @@
import sys
from util import with_app, rootdir
import pytest
from util import rootdir
def setup_module():
@@ -22,7 +23,7 @@ def teardown_module():
sys.path.remove(rootdir / 'roots' / 'test-api-set-translator')
@with_app('html')
@pytest.mark.sphinx('html')
def test_html_translator(app, status, warning):
# no set_translator(), no html_translator_class
translator_class = app.builder.translator_class
@@ -30,7 +31,7 @@ def test_html_translator(app, status, warning):
assert translator_class.__name__ == 'SmartyPantsHTMLTranslator'
@with_app('html', confoverrides={
@pytest.mark.sphinx('html', confoverrides={
'html_translator_class': 'translator.ExtHTMLTranslator'})
def test_html_with_html_translator_class(app, status, warning):
# no set_translator(), but html_translator_class
@@ -39,8 +40,8 @@ def test_html_with_html_translator_class(app, status, warning):
assert translator_class.__name__ == 'ExtHTMLTranslator'
@with_app('html',
confoverrides={'html_use_smartypants': False})
@pytest.mark.sphinx('html', confoverrides={
'html_use_smartypants': False})
def test_html_with_smartypants(app, status, warning):
# no set_translator(), html_use_smartypants=False
translator_class = app.builder.translator_class
@@ -48,7 +49,7 @@ def test_html_with_smartypants(app, status, warning):
assert translator_class.__name__ == 'HTMLTranslator'
@with_app('html', testroot='api-set-translator')
@pytest.mark.sphinx('html', testroot='api-set-translator')
def test_html_with_set_translator_for_html_(app, status, warning):
# use set_translator(), no html_translator_class
translator_class = app.builder.translator_class
@@ -56,8 +57,8 @@ def test_html_with_set_translator_for_html_(app, status, warning):
assert translator_class.__name__ == 'ConfHTMLTranslator'
@with_app('html', testroot='api-set-translator',
confoverrides={'html_translator_class': 'translator.ExtHTMLTranslator'})
@pytest.mark.sphinx('html', testroot='api-set-translator', confoverrides={
'html_translator_class': 'translator.ExtHTMLTranslator'})
def test_html_with_set_translator_for_html_and_html_translator_class(
app, status, warning):
# use set_translator() and html_translator_class.
@@ -68,7 +69,7 @@ def test_html_with_set_translator_for_html_and_html_translator_class(
# this test break test_websupport.test_comments test. why?
# @with_app(
# @pytest.mark.sphinx(
# buildername='dirhtml',
# srcdir=(test_roots / 'test-api-set-translator'),
# )
@@ -78,63 +79,63 @@ def test_html_with_set_translator_for_html_and_html_translator_class(
# assert translator_class.__name__ == 'ConfDirHTMLTranslator'
@with_app('singlehtml', testroot='api-set-translator')
@pytest.mark.sphinx('singlehtml', testroot='api-set-translator')
def test_singlehtml_set_translator_for_singlehtml(app, status, warning):
translator_class = app.builder.translator_class
assert translator_class
assert translator_class.__name__ == 'ConfSingleHTMLTranslator'
@with_app('pickle', testroot='api-set-translator')
@pytest.mark.sphinx('pickle', testroot='api-set-translator')
def test_pickle_set_translator_for_pickle(app, status, warning):
translator_class = app.builder.translator_class
assert translator_class
assert translator_class.__name__ == 'ConfPickleTranslator'
@with_app('json', testroot='api-set-translator')
@pytest.mark.sphinx('json', testroot='api-set-translator')
def test_json_set_translator_for_json(app, status, warning):
translator_class = app.builder.translator_class
assert translator_class
assert translator_class.__name__ == 'ConfJsonTranslator'
@with_app('latex', testroot='api-set-translator')
@pytest.mark.sphinx('latex', testroot='api-set-translator')
def test_html_with_set_translator_for_latex(app, status, warning):
translator_class = app.builder.translator_class
assert translator_class
assert translator_class.__name__ == 'ConfLaTeXTranslator'
@with_app('man', testroot='api-set-translator')
@pytest.mark.sphinx('man', testroot='api-set-translator')
def test_html_with_set_translator_for_man(app, status, warning):
translator_class = app.builder.translator_class
assert translator_class
assert translator_class.__name__ == 'ConfManualPageTranslator'
@with_app('texinfo', testroot='api-set-translator')
@pytest.mark.sphinx('texinfo', testroot='api-set-translator')
def test_html_with_set_translator_for_texinfo(app, status, warning):
translator_class = app.builder.translator_class
assert translator_class
assert translator_class.__name__ == 'ConfTexinfoTranslator'
@with_app('text', testroot='api-set-translator')
@pytest.mark.sphinx('text', testroot='api-set-translator')
def test_html_with_set_translator_for_text(app, status, warning):
translator_class = app.builder.translator_class
assert translator_class
assert translator_class.__name__ == 'ConfTextTranslator'
@with_app('xml', testroot='api-set-translator')
@pytest.mark.sphinx('xml', testroot='api-set-translator')
def test_html_with_set_translator_for_xml(app, status, warning):
translator_class = app.builder.translator_class
assert translator_class
assert translator_class.__name__ == 'ConfXMLTranslator'
@with_app('pseudoxml', testroot='api-set-translator')
@pytest.mark.sphinx('pseudoxml', testroot='api-set-translator')
def test_html_with_set_translator_for_pseudoxml(app, status, warning):
translator_class = app.builder.translator_class
assert translator_class

View File

@@ -15,11 +15,10 @@ from docutils import nodes
from sphinx.application import ExtensionError
from sphinx.domains import Domain
from util import with_app, strip_escseq
from util import strip_escseq
import pytest
@with_app()
def test_events(app, status, warning):
def empty():
pass
@@ -45,13 +44,11 @@ def test_events(app, status, warning):
"Callback called when disconnected"
@with_app()
def test_emit_with_nonascii_name_node(app, status, warning):
node = nodes.section(names=[u'\u65e5\u672c\u8a9e'])
app.emit('my_event', node)
@with_app()
def test_output(app, status, warning):
# info with newline
status.truncate(0) # __init__ writes to status
@@ -71,7 +68,6 @@ def test_output(app, status, warning):
assert app._warncount == old_count + 1
@with_app()
def test_output_with_unencodable_char(app, status, warning):
class StreamWriter(codecs.StreamWriter):
@@ -87,20 +83,17 @@ def test_output_with_unencodable_char(app, status, warning):
assert status.getvalue() == "unicode ?...\n"
@with_app()
def test_extensions(app, status, warning):
app.setup_extension('shutil')
assert strip_escseq(warning.getvalue()).startswith("WARNING: extension 'shutil'")
@with_app()
def test_extension_in_blacklist(app, status, warning):
app.setup_extension('sphinxjp.themecore')
msg = strip_escseq(warning.getvalue())
assert msg.startswith("WARNING: the extension 'sphinxjp.themecore' was")
@with_app()
def test_domain_override(app, status, warning):
class A(Domain):
name = 'foo'
@@ -123,7 +116,7 @@ def test_domain_override(app, status, warning):
assert 'new domain not a subclass of registered foo domain' in str(excinfo.value)
@with_app(testroot='add_source_parser')
@pytest.mark.sphinx(testroot='add_source_parser')
def test_add_source_parser(app, status, warning):
assert set(app.config.source_suffix) == set(['.rst', '.md', '.test'])
assert set(app.config.source_parsers.keys()) == set(['.md', '.test'])
@@ -131,7 +124,7 @@ def test_add_source_parser(app, status, warning):
assert app.config.source_parsers['.test'].__name__ == 'TestSourceParser'
@with_app(testroot='add_source_parser-conflicts-with-users-setting')
@pytest.mark.sphinx(testroot='add_source_parser-conflicts-with-users-setting')
def test_add_source_parser_conflicts_with_users_setting(app, status, warning):
assert set(app.config.source_suffix) == set(['.rst', '.test'])
assert set(app.config.source_parsers.keys()) == set(['.test'])

View File

@@ -9,16 +9,15 @@
:license: BSD, see LICENSE for details.
"""
from six import BytesIO
import pickle
from docutils import nodes
import mock
import pytest
from textwrap import dedent
from sphinx.errors import SphinxError
import sphinx.builders.linkcheck
from util import with_app, rootdir, tempdir, SkipTest, TestApp, path
from util import rootdir, tempdir, SkipTest, TestApp, path
try:
from docutils.writers.manpage import Writer as ManWriter
@@ -91,7 +90,7 @@ def test_master_doc_not_found(tempdir):
app.cleanup()
@with_app(buildername='text', testroot='circular')
@pytest.mark.sphinx(buildername='text', testroot='circular')
def test_circular_toctree(app, status, warning):
app.builder.build_all()
warnings = warning.getvalue()
@@ -103,7 +102,7 @@ def test_circular_toctree(app, status, warning):
'contents <- sub <- contents') in warnings
@with_app(buildername='text', testroot='numbered-circular')
@pytest.mark.sphinx(buildername='text', testroot='numbered-circular')
def test_numbered_circular_toctree(app, status, warning):
app.builder.build_all()
warnings = warning.getvalue()
@@ -115,7 +114,7 @@ def test_numbered_circular_toctree(app, status, warning):
'contents <- sub <- contents') in warnings
@with_app(buildername='dummy', testroot='image-glob')
@pytest.mark.sphinx(buildername='dummy', testroot='image-glob')
def test_image_glob(app, status, warning):
app.builder.build_all()

View File

@@ -13,7 +13,7 @@
import plistlib
from util import with_app
import pytest
from path import path
# Use plistlib.load in 3.4 and above
@@ -43,9 +43,10 @@ def check_localization(outdir):
assert (lprojdir / 'localized.txt').isfile()
@with_app(buildername='applehelp', testroot='basic', srcdir='applehelp_output',
confoverrides={'applehelp_bundle_id': 'org.sphinx-doc.Sphinx.help',
'applehelp_disable_external_tools': True})
@pytest.mark.sphinx(
'applehelp', testroot='basic', srcdir='applehelp_output',
confoverrides={'applehelp_bundle_id': 'org.sphinx-doc.Sphinx.help',
'applehelp_disable_external_tools': True})
def test_applehelp_output(app, status, warning):
(app.srcdir / 'en.lproj').makedirs()
(app.srcdir / 'en.lproj' / 'localized.txt').write_text('')

View File

@@ -15,8 +15,10 @@ import re
import gettext
from subprocess import Popen, PIPE
import pytest
from util import (
with_app, gen_with_app, SkipTest, assert_in, assert_true, assert_equal
gen_with_app, SkipTest, assert_in, assert_true, assert_equal
)
@@ -76,8 +78,9 @@ def test_all(app, status, warning):
yield assert_equal, _("Testing various markup"), u"Testing various markup"
@with_app('gettext', testroot='intl', srcdir='gettext',
confoverrides={'gettext_compact': False})
@pytest.mark.sphinx(
'gettext', testroot='intl', srcdir='gettext',
confoverrides={'gettext_compact': False})
def test_gettext_index_entries(app, status, warning):
# regression test for #976
app.builder.build(['index_entries'])
@@ -123,8 +126,9 @@ def test_gettext_index_entries(app, status, warning):
assert msgids == []
@with_app('gettext', testroot='intl', srcdir='gettext',
confoverrides={'gettext_compact': False, 'gettext_additional_targets': []})
@pytest.mark.sphinx(
'gettext', testroot='intl', srcdir='gettext',
confoverrides={'gettext_compact': False, 'gettext_additional_targets': []})
def test_gettext_disable_index_entries(app, status, warning):
# regression test for #976
app.builder.build(['index_entries'])
@@ -155,7 +159,7 @@ def test_gettext_disable_index_entries(app, status, warning):
assert msgids == []
@with_app(buildername='gettext', testroot='intl', srcdir='gettext')
@pytest.mark.sphinx('gettext', testroot='intl', srcdir='gettext')
def test_gettext_template(app, status, warning):
app.builder.build_all()
assert (app.outdir / 'sphinx.pot').isfile()

View File

@@ -15,9 +15,10 @@ import re
from six import PY3, iteritems
from sphinx import __display_version__
from util import remove_unicode_literals, gen_with_app, with_app, strip_escseq
from util import remove_unicode_literals, gen_with_app, strip_escseq
from etree13 import ElementTree
from html5lib import getTreeBuilder, HTMLParser
import pytest
TREE_BUILDER = getTreeBuilder('etree', implementation=ElementTree)
@@ -384,7 +385,7 @@ def check_extra_entries(outdir):
assert (outdir / 'robots.txt').isfile()
@with_app(buildername='html', testroot='warnings', freshenv=True)
@pytest.mark.sphinx('html', testroot='warnings', freshenv=True)
def test_html_warnings(app, status, warning):
app.builder.build_all()
html_warnings = strip_escseq(warning.getvalue().replace(os.sep, '/'))
@@ -1084,7 +1085,7 @@ def test_enumerable_node(app, status, warning):
yield check_xpath, etree, fname, xpath, check, be_found
@with_app(buildername='html', testroot='html_assets')
@pytest.mark.sphinx('html', testroot='html_assets')
def test_html_assets(app, status, warning):
app.builder.build_all()
@@ -1112,7 +1113,7 @@ def test_html_assets(app, status, warning):
assert not (app.outdir / 'subdir' / '.htpasswd').exists()
@with_app(buildername='html', confoverrides={'html_sourcelink_suffix': ''})
@pytest.mark.sphinx('html', confoverrides={'html_sourcelink_suffix': ''})
def test_html_sourcelink_suffix(app, status, warning):
app.builder.build_all()
content_otherext = (app.outdir / 'otherext.html').text()

View File

@@ -22,7 +22,7 @@ from sphinx.errors import SphinxError
from sphinx.util.osutil import cd, ensuredir
from sphinx.writers.latex import LaTeXTranslator
from util import SkipTest, remove_unicode_literals, with_app, strip_escseq, skip_if
from util import SkipTest, remove_unicode_literals, strip_escseq, skip_if
from test_build_html import ENV_WARNINGS
@@ -109,7 +109,7 @@ def test_build_latex_doc(app, status, warning, engine, docclass):
compile_latex_document(app)
@with_app(buildername='latex')
@pytest.mark.sphinx('latex')
def test_writer(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'SphinxTests.tex').text(encoding='utf8')
@@ -137,7 +137,7 @@ def test_writer(app, status, warning):
'\\end{wrapfigure}' in result)
@with_app(buildername='latex', testroot='warnings', freshenv=True)
@pytest.mark.sphinx('latex', testroot='warnings', freshenv=True)
def test_latex_warnings(app, status, warning):
app.builder.build_all()
@@ -150,7 +150,7 @@ def test_latex_warnings(app, status, warning):
'--- Got:\n' + warnings
@with_app(buildername='latex', testroot='basic')
@pytest.mark.sphinx('latex', testroot='basic')
def test_latex_title(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'test.tex').text(encoding='utf8')
@@ -160,7 +160,7 @@ def test_latex_title(app, status, warning):
assert '\\title{The basic Sphinx documentation for testing}' in result
@with_app(buildername='latex', testroot='latex-title')
@pytest.mark.sphinx('latex', testroot='latex-title')
def test_latex_title_after_admonitions(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'test.tex').text(encoding='utf8')
@@ -170,7 +170,7 @@ def test_latex_title_after_admonitions(app, status, warning):
assert '\\title{test-latex-title}' in result
@with_app(buildername='latex', testroot='numfig',
@pytest.mark.sphinx('latex', testroot='numfig',
confoverrides={'numfig': True})
def test_numref(app, status, warning):
app.builder.build_all()
@@ -203,12 +203,13 @@ def test_numref(app, status, warning):
'\\nameref{\\detokenize{foo:foo}}}') in result
@with_app(buildername='latex', testroot='numfig',
confoverrides={'numfig': True,
'numfig_format': {'figure': 'Figure:%s',
'table': 'Tab_%s',
'code-block': 'Code-%s',
'section': 'SECTION-%s'}})
@pytest.mark.sphinx(
'latex', testroot='numfig',
confoverrides={'numfig': True,
'numfig_format': {'figure': 'Figure:%s',
'table': 'Tab_%s',
'code-block': 'Code-%s',
'section': 'SECTION-%s'}})
def test_numref_with_prefix1(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
@@ -246,12 +247,13 @@ def test_numref_with_prefix1(app, status, warning):
'\\nameref{\\detokenize{foo:foo}}}') in result
@with_app(buildername='latex', testroot='numfig',
confoverrides={'numfig': True,
'numfig_format': {'figure': 'Figure:%s.',
'table': 'Tab_%s:',
'code-block': 'Code-%s | ',
'section': 'SECTION_%s_'}})
@pytest.mark.sphinx(
'latex', testroot='numfig',
confoverrides={'numfig': True,
'numfig_format': {'figure': 'Figure:%s.',
'table': 'Tab_%s:',
'code-block': 'Code-%s | ',
'section': 'SECTION_%s_'}})
def test_numref_with_prefix2(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
@@ -285,8 +287,9 @@ def test_numref_with_prefix2(app, status, warning):
'\\nameref{\\detokenize{foo:foo}}}') in result
@with_app(buildername='latex', testroot='numfig',
confoverrides={'numfig': True, 'language': 'ja'})
@pytest.mark.sphinx(
'latex', testroot='numfig',
confoverrides={'numfig': True, 'language': 'ja'})
def test_numref_with_language_ja(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
@@ -318,7 +321,7 @@ def test_numref_with_language_ja(app, status, warning):
'\\nameref{\\detokenize{foo:foo}}}') in result
@with_app(buildername='latex')
@pytest.mark.sphinx('latex')
def test_latex_add_latex_package(app, status, warning):
app.add_latex_package('foo')
app.add_latex_package('bar', 'baz')
@@ -328,7 +331,7 @@ def test_latex_add_latex_package(app, status, warning):
assert '\\usepackage[baz]{bar}' in result
@with_app(buildername='latex', testroot='latex-babel')
@pytest.mark.sphinx('latex', testroot='latex-babel')
def test_babel_with_no_language_settings(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
@@ -347,8 +350,9 @@ def test_babel_with_no_language_settings(app, status, warning):
assert '\\shorthandoff' not in result
@with_app(buildername='latex', testroot='latex-babel',
confoverrides={'language': 'de'})
@pytest.mark.sphinx(
'latex', testroot='latex-babel',
confoverrides={'language': 'de'})
def test_babel_with_language_de(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
@@ -367,8 +371,9 @@ def test_babel_with_language_de(app, status, warning):
assert '\\shorthandoff{"}' in result
@with_app(buildername='latex', testroot='latex-babel',
confoverrides={'language': 'ru'})
@pytest.mark.sphinx(
'latex', testroot='latex-babel',
confoverrides={'language': 'ru'})
def test_babel_with_language_ru(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
@@ -388,8 +393,9 @@ def test_babel_with_language_ru(app, status, warning):
assert '\\shorthandoff' not in result
@with_app(buildername='latex', testroot='latex-babel',
confoverrides={'language': 'tr'})
@pytest.mark.sphinx(
'latex', testroot='latex-babel',
confoverrides={'language': 'tr'})
def test_babel_with_language_tr(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
@@ -408,8 +414,9 @@ def test_babel_with_language_tr(app, status, warning):
assert '\\shorthandoff{=}' in result
@with_app(buildername='latex', testroot='latex-babel',
confoverrides={'language': 'ja'})
@pytest.mark.sphinx(
'latex', testroot='latex-babel',
confoverrides={'language': 'ja'})
def test_babel_with_language_ja(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
@@ -427,8 +434,9 @@ def test_babel_with_language_ja(app, status, warning):
assert '\\shorthandoff' not in result
@with_app(buildername='latex', testroot='latex-babel',
confoverrides={'language': 'unknown'})
@pytest.mark.sphinx(
'latex', testroot='latex-babel',
confoverrides={'language': 'unknown'})
def test_babel_with_unknown_language(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
@@ -449,7 +457,7 @@ def test_babel_with_unknown_language(app, status, warning):
assert "WARNING: no Babel option known for language 'unknown'" in warning.getvalue()
@with_app(buildername='latex')
@pytest.mark.sphinx('latex')
def test_footnote(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'SphinxTests.tex').text(encoding='utf8')
@@ -479,7 +487,7 @@ def test_footnote(app, status, warning):
'footnotes in table\n%\n\\end{footnotetext}') in result
@with_app(buildername='latex', testroot='footnotes')
@pytest.mark.sphinx('latex', testroot='footnotes')
def test_reference_in_caption_and_codeblock_in_footnote(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
@@ -516,8 +524,9 @@ def test_reference_in_caption_and_codeblock_in_footnote(app, status, warning):
assert '\\begin{sphinxVerbatim}[commandchars=\\\\\\{\\}]' in result
@with_app(buildername='latex', testroot='footnotes',
confoverrides={'latex_show_urls': 'inline'})
@pytest.mark.sphinx(
'latex', testroot='footnotes',
confoverrides={'latex_show_urls': 'inline'})
def test_latex_show_urls_is_inline(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
@@ -559,8 +568,9 @@ def test_latex_show_urls_is_inline(app, status, warning):
'{sphinx-dev@googlegroups.com}') in result
@with_app(buildername='latex', testroot='footnotes',
confoverrides={'latex_show_urls': 'footnote'})
@pytest.mark.sphinx(
'latex', testroot='footnotes',
confoverrides={'latex_show_urls': 'footnote'})
def test_latex_show_urls_is_footnote(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
@@ -610,8 +620,9 @@ def test_latex_show_urls_is_footnote(app, status, warning):
'{sphinx-dev@googlegroups.com}\n') in result
@with_app(buildername='latex', testroot='footnotes',
confoverrides={'latex_show_urls': 'no'})
@pytest.mark.sphinx(
'latex', testroot='footnotes',
confoverrides={'latex_show_urls': 'no'})
def test_latex_show_urls_is_no(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
@@ -651,7 +662,7 @@ def test_latex_show_urls_is_no(app, status, warning):
'{sphinx-dev@googlegroups.com}\n') in result
@with_app(buildername='latex', testroot='image-in-section')
@pytest.mark.sphinx('latex', testroot='image-in-section')
def test_image_in_section(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
@@ -667,7 +678,7 @@ def test_image_in_section(app, status, warning):
assert ('\\chapter{Another section}' in result)
@with_app(buildername='latex', confoverrides={'latex_logo': 'notfound.jpg'})
@pytest.mark.sphinx('latex', confoverrides={'latex_logo': 'notfound.jpg'})
def test_latex_logo_if_not_found(app, status, warning):
try:
app.builder.build_all()
@@ -676,7 +687,7 @@ def test_latex_logo_if_not_found(app, status, warning):
assert isinstance(exc, SphinxError)
@with_app(buildername='latex', testroot='toctree-maxdepth',
@pytest.mark.sphinx('latex', testroot='toctree-maxdepth',
confoverrides={'latex_documents': [
('index', 'SphinxTests.tex', 'Sphinx Tests Documentation',
'Georg Brandl', 'manual'),
@@ -691,11 +702,12 @@ def test_toctree_maxdepth_manual(app, status, warning):
assert '\\setcounter{secnumdepth}' not in result
@with_app(buildername='latex', testroot='toctree-maxdepth',
confoverrides={'latex_documents': [
('index', 'SphinxTests.tex', 'Sphinx Tests Documentation',
'Georg Brandl', 'howto'),
]})
@pytest.mark.sphinx(
'latex', testroot='toctree-maxdepth',
confoverrides={'latex_documents': [
('index', 'SphinxTests.tex', 'Sphinx Tests Documentation',
'Georg Brandl', 'howto'),
]})
def test_toctree_maxdepth_howto(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'SphinxTests.tex').text(encoding='utf8')
@@ -706,8 +718,9 @@ def test_toctree_maxdepth_howto(app, status, warning):
assert '\\setcounter{secnumdepth}' not in result
@with_app(buildername='latex', testroot='toctree-maxdepth',
confoverrides={'master_doc': 'foo'})
@pytest.mark.sphinx(
'latex', testroot='toctree-maxdepth',
confoverrides={'master_doc': 'foo'})
def test_toctree_not_found(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
@@ -718,8 +731,9 @@ def test_toctree_not_found(app, status, warning):
assert '\\setcounter{secnumdepth}' not in result
@with_app(buildername='latex', testroot='toctree-maxdepth',
confoverrides={'master_doc': 'bar'})
@pytest.mark.sphinx(
'latex', testroot='toctree-maxdepth',
confoverrides={'master_doc': 'bar'})
def test_toctree_without_maxdepth(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
@@ -730,8 +744,9 @@ def test_toctree_without_maxdepth(app, status, warning):
assert '\\setcounter{secnumdepth}' not in result
@with_app(buildername='latex', testroot='toctree-maxdepth',
confoverrides={'master_doc': 'qux'})
@pytest.mark.sphinx(
'latex', testroot='toctree-maxdepth',
confoverrides={'master_doc': 'qux'})
def test_toctree_with_deeper_maxdepth(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
@@ -742,8 +757,9 @@ def test_toctree_with_deeper_maxdepth(app, status, warning):
assert '\\setcounter{secnumdepth}{3}' in result
@with_app(buildername='latex', testroot='toctree-maxdepth',
confoverrides={'latex_toplevel_sectioning': None})
@pytest.mark.sphinx(
'latex', testroot='toctree-maxdepth',
confoverrides={'latex_toplevel_sectioning': None})
def test_latex_toplevel_sectioning_is_None(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
@@ -753,8 +769,9 @@ def test_latex_toplevel_sectioning_is_None(app, status, warning):
assert '\\chapter{Foo}' in result
@with_app(buildername='latex', testroot='toctree-maxdepth',
confoverrides={'latex_toplevel_sectioning': 'part'})
@pytest.mark.sphinx(
'latex', testroot='toctree-maxdepth',
confoverrides={'latex_toplevel_sectioning': 'part'})
def test_latex_toplevel_sectioning_is_part(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
@@ -764,8 +781,9 @@ def test_latex_toplevel_sectioning_is_part(app, status, warning):
assert '\\part{Foo}' in result
@with_app(buildername='latex', testroot='toctree-maxdepth',
confoverrides={'latex_toplevel_sectioning': 'chapter'})
@pytest.mark.sphinx(
'latex', testroot='toctree-maxdepth',
confoverrides={'latex_toplevel_sectioning': 'chapter'})
def test_latex_toplevel_sectioning_is_chapter(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
@@ -775,8 +793,9 @@ def test_latex_toplevel_sectioning_is_chapter(app, status, warning):
assert '\\chapter{Foo}' in result
@with_app(buildername='latex', testroot='toctree-maxdepth',
confoverrides={'latex_toplevel_sectioning': 'section'})
@pytest.mark.sphinx(
'latex', testroot='toctree-maxdepth',
confoverrides={'latex_toplevel_sectioning': 'section'})
def test_latex_toplevel_sectioning_is_section(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
@@ -786,7 +805,7 @@ def test_latex_toplevel_sectioning_is_section(app, status, warning):
assert '\\section{Foo}' in result
@skip_if_stylefiles_notfound
@with_app(buildername='latex', testroot='maxlistdepth')
@pytest.mark.sphinx('latex', testroot='maxlistdepth')
def test_maxlistdepth_at_ten(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'SphinxTests.tex').text(encoding='utf8')

View File

@@ -10,10 +10,10 @@
"""
from __future__ import print_function
from util import with_app
import pytest
@with_app('linkcheck', testroot='linkcheck', freshenv=True)
@pytest.mark.sphinx('linkcheck', testroot='linkcheck', freshenv=True)
def test_defaults(app, status, warning):
app.builder.build_all()
@@ -26,8 +26,9 @@ def test_defaults(app, status, warning):
assert len(content.splitlines()) == 1
@with_app('linkcheck', testroot='linkcheck', freshenv=True,
confoverrides={'linkcheck_anchors_ignore': ["^!", "^top$"]})
@pytest.mark.sphinx(
'linkcheck', testroot='linkcheck', freshenv=True,
confoverrides={'linkcheck_anchors_ignore': ["^!", "^top$"]})
def test_anchors_ignored(app, status, warning):
app.builder.build_all()

View File

@@ -10,10 +10,10 @@
"""
from __future__ import print_function
from util import with_app
import pytest
@with_app(buildername='man')
@pytest.mark.sphinx('man')
def test_all(app, status, warning):
app.builder.build_all()
assert (app.outdir / 'SphinxTests.1').exists()

View File

@@ -15,10 +15,11 @@ import re
from subprocess import Popen, PIPE
from six import PY3
import pytest
from sphinx.writers.texinfo import TexinfoTranslator
from util import SkipTest, remove_unicode_literals, with_app, strip_escseq
from util import SkipTest, remove_unicode_literals, strip_escseq
from test_build_html import ENV_WARNINGS
@@ -33,7 +34,7 @@ if PY3:
TEXINFO_WARNINGS = remove_unicode_literals(TEXINFO_WARNINGS)
@with_app(buildername='texinfo', testroot='warnings', freshenv=True)
@pytest.mark.sphinx('texinfo', testroot='warnings', freshenv=True)
def test_texinfo_warnings(app, status, warning):
app.builder.build_all()
warnings = strip_escseq(warning.getvalue().replace(os.sep, '/'))
@@ -45,7 +46,7 @@ def test_texinfo_warnings(app, status, warning):
'--- Got:\n' + warnings
@with_app(buildername='texinfo')
@pytest.mark.sphinx('texinfo')
def test_texinfo(app, status, warning):
TexinfoTranslator.ignore_missing_images = True
app.builder.build_all()

View File

@@ -12,7 +12,7 @@ import shutil
import pytest
from util import with_app, find_files, rootdir, tempdir
from util import find_files, rootdir, tempdir
root = tempdir / 'test-intl'
build_dir = root / '_build'
@@ -37,8 +37,9 @@ def setup_test():
@pytest.mark.usefixtures('setup_test')
@with_app(buildername='html', testroot='intl',
confoverrides={'language': 'en', 'locale_dirs': [locale_dir]})
@pytest.mark.sphinx(
'html', testroot='intl',
confoverrides={'language': 'en', 'locale_dirs': [locale_dir]})
def test_compile_all_catalogs(app, status, warning):
app.builder.compile_all_catalogs()
@@ -53,8 +54,9 @@ def test_compile_all_catalogs(app, status, warning):
@pytest.mark.usefixtures('setup_test')
@with_app(buildername='html', testroot='intl',
confoverrides={'language': 'en', 'locale_dirs': [locale_dir]})
@pytest.mark.sphinx(
'html', testroot='intl',
confoverrides={'language': 'en', 'locale_dirs': [locale_dir]})
def test_compile_specific_catalogs(app, status, warning):
catalog_dir = locale_dir / app.config.language / 'LC_MESSAGES'
@@ -68,8 +70,9 @@ def test_compile_specific_catalogs(app, status, warning):
@pytest.mark.usefixtures('setup_test')
@with_app(buildername='html', testroot='intl',
confoverrides={'language': 'en', 'locale_dirs': [locale_dir]})
@pytest.mark.sphinx(
'html', testroot='intl',
confoverrides={'language': 'en', 'locale_dirs': [locale_dir]})
def test_compile_update_catalogs(app, status, warning):
app.builder.compile_update_catalogs()

View File

@@ -13,7 +13,7 @@ from six import PY3, iteritems
import pytest
import mock
from util import TestApp, with_app, gen_with_app, \
from util import TestApp, gen_with_app, \
assert_in, assert_not_in
import sphinx
@@ -21,9 +21,11 @@ from sphinx.config import Config
from sphinx.errors import ExtensionError, ConfigError, VersionRequirementError
@with_app(confoverrides={'master_doc': 'master', 'nonexisting_value': 'True',
'latex_elements.docclass': 'scrartcl',
'modindex_common_prefix': 'path1,path2'})
@pytest.mark.sphinx(confoverrides={
'master_doc': 'master',
'nonexisting_value': 'True',
'latex_elements.docclass': 'scrartcl',
'modindex_common_prefix': 'path1,path2'})
def test_core_config(app, status, warning):
cfg = app.config
@@ -74,7 +76,7 @@ def test_core_config(app, status, warning):
assert cfg['project'] == cfg.project == 'Sphinx Tests'
@with_app()
@pytest.mark.sphinx()
def test_extension_values(app, status, warning):
cfg = app.config
@@ -169,7 +171,7 @@ def test_config_eol(tempdir):
assert cfg.project == u'spam'
@with_app(confoverrides={'master_doc': 123,
@pytest.mark.sphinx(confoverrides={'master_doc': 123,
'language': 'foo',
'primary_domain': None})
def test_builtin_conf(app, status, warning):
@@ -215,13 +217,13 @@ def test_gen_check_types(app, status, warning):
)
@with_app(testroot='config')
@pytest.mark.sphinx(testroot='config')
def test_check_enum(app, status, warning):
assert "The config value `value17` has to be a one of ('default', 'one', 'two'), " \
not in warning.getvalue()
@with_app(testroot='config', confoverrides={'value17': 'invalid'})
@pytest.mark.sphinx(testroot='config', confoverrides={'value17': 'invalid'})
def test_check_enum_failed(app, status, warning):
assert "The config value `value17` has to be a one of ('default', 'one', 'two'), " \
"but `invalid` is given." in warning.getvalue()

View File

@@ -9,10 +9,12 @@
:license: BSD, see LICENSE for details.
"""
from util import with_app, etree_parse
import pytest
from util import etree_parse
@with_app('xml', testroot='directive-code')
@pytest.mark.sphinx('xml', testroot='directive-code')
def test_code_block(app, status, warning):
app.builder.build('index')
et = etree_parse(app.outdir / 'index.xml')
@@ -28,7 +30,7 @@ def test_code_block(app, status, warning):
assert actual == expect
@with_app('xml', testroot='directive-code')
@pytest.mark.sphinx('xml', testroot='directive-code')
def test_code_block_dedent(app, status, warning):
app.builder.build(['dedent_code'])
et = etree_parse(app.outdir / 'dedent_code.xml')
@@ -47,7 +49,7 @@ def test_code_block_dedent(app, status, warning):
assert blocks[5].text == '\n\n' # dedent: 1000
@with_app('html', testroot='directive-code')
@pytest.mark.sphinx('html', testroot='directive-code')
def test_code_block_caption_html(app, status, warning):
app.builder.build(['caption'])
html = (app.outdir / 'caption.html').text(encoding='utf-8')
@@ -59,7 +61,7 @@ def test_code_block_caption_html(app, status, warning):
assert caption in html
@with_app('latex', testroot='directive-code')
@pytest.mark.sphinx('latex', testroot='directive-code')
def test_code_block_caption_latex(app, status, warning):
app.builder.build_all()
latex = (app.outdir / 'Python.tex').text(encoding='utf-8')
@@ -72,7 +74,7 @@ def test_code_block_caption_latex(app, status, warning):
assert link in latex
@with_app('latex', testroot='directive-code')
@pytest.mark.sphinx('latex', testroot='directive-code')
def test_code_block_namedlink_latex(app, status, warning):
app.builder.build_all()
latex = (app.outdir / 'Python.tex').text(encoding='utf-8')
@@ -89,7 +91,7 @@ def test_code_block_namedlink_latex(app, status, warning):
assert link2 in latex
@with_app('xml', testroot='directive-code')
@pytest.mark.sphinx('xml', testroot='directive-code')
def test_literal_include(app, status, warning):
app.builder.build(['index'])
et = etree_parse(app.outdir / 'index.xml')
@@ -101,7 +103,7 @@ def test_literal_include(app, status, warning):
assert actual == literal_src
@with_app('xml', testroot='directive-code')
@pytest.mark.sphinx('xml', testroot='directive-code')
def test_literal_include_dedent(app, status, warning):
literal_src = (app.srcdir / 'literal.inc').text(encoding='utf-8')
literal_lines = [l[4:] for l in literal_src.split('\n')[9:11]]
@@ -119,7 +121,7 @@ def test_literal_include_dedent(app, status, warning):
assert blocks[5].text == '\n\n' # dedent: 1000
@with_app('xml', testroot='directive-code')
@pytest.mark.sphinx('xml', testroot='directive-code')
def test_literal_include_block_start_with_comment_or_brank(app, status, warning):
app.builder.build(['python'])
et = etree_parse(app.outdir / 'python.xml')
@@ -143,7 +145,7 @@ def test_literal_include_block_start_with_comment_or_brank(app, status, warning)
assert actual == expect
@with_app('html', testroot='directive-code')
@pytest.mark.sphinx('html', testroot='directive-code')
def test_literal_include_linenos(app, status, warning):
app.builder.build(['linenos'])
html = (app.outdir / 'linenos.html').text(encoding='utf-8')
@@ -166,7 +168,7 @@ def test_literal_include_linenos(app, status, warning):
assert linenos in html
@with_app('html', testroot='directive-code')
@pytest.mark.sphinx('html', testroot='directive-code')
def test_literal_include_lineno_start(app, status, warning):
app.builder.build(['lineno_start'])
html = (app.outdir / 'lineno_start.html').text(encoding='utf-8')
@@ -189,7 +191,7 @@ def test_literal_include_lineno_start(app, status, warning):
assert linenos in html
@with_app('html', testroot='directive-code')
@pytest.mark.sphinx('html', testroot='directive-code')
def test_literal_include_lineno_match(app, status, warning):
app.builder.build(['lineno_match'])
html = (app.outdir / 'lineno_match.html').text(encoding='utf-8')
@@ -229,7 +231,7 @@ def test_literal_include_lineno_match(app, status, warning):
assert start_at_end_at in html
@with_app('latex', testroot='directive-code')
@pytest.mark.sphinx('latex', testroot='directive-code')
def test_literalinclude_file_whole_of_emptyline(app, status, warning):
app.builder.build_all()
latex = (app.outdir / 'Python.tex').text(encoding='utf-8').replace('\r\n', '\n')
@@ -243,7 +245,7 @@ def test_literalinclude_file_whole_of_emptyline(app, status, warning):
assert includes in latex
@with_app('html', testroot='directive-code')
@pytest.mark.sphinx('html', testroot='directive-code')
def test_literalinclude_caption_html(app, status, warning):
app.builder.build('index')
html = (app.outdir / 'caption.html').text(encoding='utf-8')
@@ -255,7 +257,7 @@ def test_literalinclude_caption_html(app, status, warning):
assert caption in html
@with_app('latex', testroot='directive-code')
@pytest.mark.sphinx('latex', testroot='directive-code')
def test_literalinclude_caption_latex(app, status, warning):
app.builder.build('index')
latex = (app.outdir / 'Python.tex').text(encoding='utf-8')
@@ -268,7 +270,7 @@ def test_literalinclude_caption_latex(app, status, warning):
assert link in latex
@with_app('latex', testroot='directive-code')
@pytest.mark.sphinx('latex', testroot='directive-code')
def test_literalinclude_namedlink_latex(app, status, warning):
app.builder.build('index')
latex = (app.outdir / 'Python.tex').text(encoding='utf-8')
@@ -285,7 +287,7 @@ def test_literalinclude_namedlink_latex(app, status, warning):
assert link2 in latex
@with_app('xml', testroot='directive-code')
@pytest.mark.sphinx('xml', testroot='directive-code')
def test_literalinclude_classes(app, status, warning):
app.builder.build(['classes'])
et = etree_parse(app.outdir / 'classes.xml')

View File

@@ -13,11 +13,10 @@ import re
from docutils import nodes
from sphinx.util.nodes import process_only_nodes
from util import with_app
import pytest
@with_app('text', testroot='directive-only')
@pytest.mark.sphinx('text', testroot='directive-only')
def test_sectioning(app, status, warning):
def getsects(section):

View File

@@ -11,14 +11,15 @@
import re
from util import with_app, path, SkipTest
import pytest
from util import path, SkipTest
def regex_count(expr, result):
return len(re.findall(expr, result))
@with_app('html', testroot='docutilsconf', freshenv=True, docutilsconf='')
@pytest.mark.sphinx('html', testroot='docutilsconf', freshenv=True, docutilsconf='')
def test_html_with_default_docutilsconf(app, status, warning):
app.builder.build(['contents'])
result = (app.outdir / 'contents.html').text(encoding='utf-8')
@@ -29,7 +30,7 @@ def test_html_with_default_docutilsconf(app, status, warning):
assert regex_count(r'<td class="option-group" colspan="2">', result) == 1
@with_app('html', testroot='docutilsconf', freshenv=True, docutilsconf=(
@pytest.mark.sphinx('html', testroot='docutilsconf', freshenv=True, docutilsconf=(
'\n[html4css1 writer]'
'\noption-limit:1'
'\nfield-name-limit:1'
@@ -45,31 +46,31 @@ def test_html_with_docutilsconf(app, status, warning):
assert regex_count(r'<td class="option-group" colspan="2">', result) == 2
@with_app('html', testroot='docutilsconf')
@pytest.mark.sphinx('html', testroot='docutilsconf')
def test_html(app, status, warning):
app.builder.build(['contents'])
assert warning.getvalue() == ''
@with_app('latex', testroot='docutilsconf')
@pytest.mark.sphinx('latex', testroot='docutilsconf')
def test_latex(app, status, warning):
app.builder.build(['contents'])
assert warning.getvalue() == ''
@with_app('man', testroot='docutilsconf')
@pytest.mark.sphinx('man', testroot='docutilsconf')
def test_man(app, status, warning):
app.builder.build(['contents'])
assert warning.getvalue() == ''
@with_app('texinfo', testroot='docutilsconf')
@pytest.mark.sphinx('texinfo', testroot='docutilsconf')
def test_texinfo(app, status, warning):
app.builder.build(['contents'])
@with_app('html', testroot='docutilsconf',
docutilsconf='[general]\nsource_link=true\n')
@pytest.mark.sphinx('html', testroot='docutilsconf',
docutilsconf='[general]\nsource_link=true\n')
def test_docutils_source_link_with_nonascii_file(app, status, warning):
srcdir = path(app.srcdir)
mb_name = u'\u65e5\u672c\u8a9e'

View File

@@ -14,8 +14,6 @@ import re
from six import text_type
import pytest
from util import with_app
from sphinx import addnodes
from sphinx.domains.cpp import DefinitionParser, DefinitionError, NoOldIdError
from sphinx.domains.cpp import Symbol
@@ -505,7 +503,7 @@ def test_attributes():
# raise DefinitionError("")
@with_app(testroot='domain-cpp', confoverrides={'add_function_parentheses': True})
@pytest.mark.sphinx(testroot='domain-cpp', confoverrides={'add_function_parentheses': True})
def test_build_domain_cpp_with_add_function_parentheses_is_True(app, status, warning):
app.builder.build_all()
@@ -542,7 +540,8 @@ def test_build_domain_cpp_with_add_function_parentheses_is_True(app, status, war
check(s, t, f)
@with_app(testroot='domain-cpp', confoverrides={'add_function_parentheses': False})
@pytest.mark.sphinx(testroot='domain-cpp', confoverrides={
'add_function_parentheses': False})
def test_build_domain_cpp_with_add_function_parentheses_is_False(app, status, warning):
app.builder.build_all()

View File

@@ -14,8 +14,9 @@ from docutils.nodes import bullet_list, list_item, caption, comment, reference
from sphinx import addnodes
from sphinx.addnodes import compact_paragraph, only
from sphinx.builders.html import StandaloneHTMLBuilder
import pytest
from util import with_app, gen_with_app, assert_node
from util import gen_with_app, assert_node
@gen_with_app('xml', testroot='toctree')
@@ -97,7 +98,7 @@ def _test_process_doc(app):
assert 'qux' not in app.env.toctree_includes
@with_app('dummy', testroot='toctree-glob')
@pytest.mark.sphinx('dummy', testroot='toctree-glob')
def test_glob(app, status, warning):
includefiles = ['foo', 'bar/index', 'bar/bar_1', 'bar/bar_2',
'bar/bar_3', 'baz', 'qux/index']

View File

@@ -10,12 +10,11 @@
"""
import pickle
from docutils import nodes
import pytest
from sphinx import addnodes
from util import with_app
@with_app(buildername='dummy', testroot='ext-autodoc')
@pytest.mark.sphinx('dummy', testroot='ext-autodoc')
def test_autodoc(app, status, warning):
app.builder.build_all()

View File

@@ -11,10 +11,10 @@
import re
from util import with_app
import pytest
@with_app('html', testroot='ext-autosectionlabel')
@pytest.mark.sphinx('html', testroot='ext-autosectionlabel')
def test_autosectionlabel_html(app, status, warning):
app.builder.build_all()

View File

@@ -13,7 +13,7 @@ from six import iteritems, StringIO
from sphinx.ext.autosummary import mangle_signature
from util import with_app
import pytest
html_warnfile = StringIO()
@@ -54,7 +54,7 @@ def test_mangle_signature():
assert res == outp, (u"'%s' -> '%s' != '%s'" % (inp, res, outp))
@with_app(buildername='dummy', **default_kw)
@pytest.mark.sphinx('dummy', **default_kw)
def test_get_items_summary(app, status, warning):
# monkey-patch Autosummary.get_items so we can easily get access to it's
# results..

View File

@@ -11,10 +11,10 @@
import pickle
from util import with_app
import pytest
@with_app(buildername='coverage')
@pytest.mark.sphinx('coverage')
def test_build(app, status, warning):
app.builder.build_all()

View File

@@ -8,13 +8,12 @@
:copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from util import with_app
import pytest
cleanup_called = 0
@with_app(buildername='doctest', testroot='doctest')
@pytest.mark.sphinx('doctest', testroot='doctest')
def test_build(app, status, warning):
global cleanup_called
cleanup_called = 0

View File

@@ -9,10 +9,10 @@
:license: BSD, see LICENSE for details.
"""
from util import with_app
import pytest
@with_app('html', testroot='ext-githubpages')
@pytest.mark.sphinx('html', testroot='ext-githubpages')
def test_githubpages(app, status, warning):
app.builder.build_all()
assert (app.outdir / '.nojekyll').exists()

View File

@@ -13,10 +13,8 @@ import re
import pytest
from util import with_app, SkipTest
@with_app('html', testroot='ext-graphviz')
@pytest.mark.sphinx('html', testroot='ext-graphviz')
@pytest.mark.usefixtures('if_graphviz_found')
def test_graphviz_html(app, status, warning):
app.builder.build_all()
@@ -37,7 +35,7 @@ def test_graphviz_html(app, status, warning):
assert re.search(html, content, re.S)
@with_app('latex', testroot='ext-graphviz')
@pytest.mark.sphinx('latex', testroot='ext-graphviz')
@pytest.mark.usefixtures('if_graphviz_found')
def test_graphviz_latex(app, status, warning):
app.builder.build_all()
@@ -57,7 +55,7 @@ def test_graphviz_latex(app, status, warning):
assert re.search(macro, content, re.S)
@with_app('html', testroot='ext-graphviz', confoverrides={'language': 'xx'})
@pytest.mark.sphinx('html', testroot='ext-graphviz', confoverrides={'language': 'xx'})
@pytest.mark.usefixtures('if_graphviz_found')
def test_graphviz_i18n(app, status, warning):
app.builder.build_all()

View File

@@ -9,10 +9,10 @@
:license: BSD, see LICENSE for details.
"""
from util import with_app
import pytest
@with_app(buildername='text', testroot='ext-ifconfig')
@pytest.mark.sphinx('text', testroot='ext-ifconfig')
def test_ifconfig(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'index.txt').text()

View File

@@ -11,12 +11,12 @@
import re
import sys
from util import with_app, rootdir
from util import rootdir
from sphinx.ext.inheritance_diagram import InheritanceException, import_classes
import pytest
@with_app('html', testroot='ext-inheritance_diagram')
@pytest.mark.sphinx('html', testroot='ext-inheritance_diagram')
@pytest.mark.usefixtures('if_graphviz_found')
def test_inheritance_diagram_html(app, status, warning):
app.builder.build_all()
@@ -31,7 +31,7 @@ def test_inheritance_diagram_html(app, status, warning):
assert re.search(pattern, content, re.M)
@with_app('latex', testroot='ext-inheritance_diagram')
@pytest.mark.sphinx('latex', testroot='ext-inheritance_diagram')
@pytest.mark.usefixtures('if_graphviz_found')
def test_inheritance_diagram_latex(app, status, warning):
app.builder.build_all()

View File

@@ -23,8 +23,6 @@ from sphinx.ext.intersphinx import read_inventory, \
load_mappings, missing_reference, _strip_basic_auth, _read_from_url, \
_get_safe_url, fetch_inventory, INVENTORY_FILENAME
from util import with_app
inventory_v1 = '''\
# Sphinx inventory version 1
@@ -82,7 +80,6 @@ def test_read_inventory_v2():
'/util/glossary.html#term-a-term-including-colon'
@with_app()
@mock.patch('sphinx.ext.intersphinx.read_inventory')
@mock.patch('sphinx.ext.intersphinx._read_from_url')
def test_fetch_inventory_redirection(_read_from_url, read_inventory, app, status, warning):
@@ -127,7 +124,6 @@ def test_fetch_inventory_redirection(_read_from_url, read_inventory, app, status
assert read_inventory.call_args[0][1] == 'http://hostname/'
@with_app()
def test_missing_reference(tempdir, app, status, warning):
inv_file = tempdir / 'inventory'
inv_file.write_bytes(inventory_v2)
@@ -217,7 +213,6 @@ def test_missing_reference(tempdir, app, status, warning):
assert rn['refuri'] == '../../../../py3k/foo.html#module-module1'
@with_app()
def test_load_mappings_warnings(tempdir, app, status, warning):
"""
load_mappings issues a warning if new-style mapping

View File

@@ -11,11 +11,13 @@
import re
from util import with_app, SkipTest
import pytest
from util import SkipTest
@with_app(buildername='html', testroot='ext-math',
confoverrides = {'extensions': ['sphinx.ext.jsmath'], 'jsmath_path': 'dummy.js'})
@pytest.mark.sphinx(
'html', testroot='ext-math',
confoverrides = {'extensions': ['sphinx.ext.jsmath'], 'jsmath_path': 'dummy.js'})
def test_jsmath(app, status, warning):
app.builder.build_all()
content = (app.outdir / 'math.html').text()
@@ -33,7 +35,7 @@ def test_jsmath(app, status, warning):
assert '<div class="math">\na + 1 &lt; b</div>' in content
@with_app('html', testroot='ext-math-simple',
@pytest.mark.sphinx('html', testroot='ext-math-simple',
confoverrides = {'extensions': ['sphinx.ext.imgmath']})
def test_imgmath_png(app, status, warning):
app.builder.build_all()
@@ -48,7 +50,7 @@ def test_imgmath_png(app, status, warning):
assert re.search(html, content, re.S)
@with_app('html', testroot='ext-math-simple',
@pytest.mark.sphinx('html', testroot='ext-math-simple',
confoverrides={'extensions': ['sphinx.ext.imgmath'],
'imgmath_image_format': 'svg'})
def test_imgmath_svg(app, status, warning):
@@ -64,7 +66,7 @@ def test_imgmath_svg(app, status, warning):
assert re.search(html, content, re.S)
@with_app('html', testroot='ext-math',
@pytest.mark.sphinx('html', testroot='ext-math',
confoverrides={'extensions': ['sphinx.ext.mathjax']})
def test_mathjax_align(app, status, warning):
app.builder.build_all()
@@ -76,7 +78,7 @@ def test_mathjax_align(app, status, warning):
assert re.search(html, content, re.S)
@with_app('html', testroot='ext-math',
@pytest.mark.sphinx('html', testroot='ext-math',
confoverrides={'math_number_all': True,
'extensions': ['sphinx.ext.mathjax']})
def test_math_number_all_mathjax(app, status, warning):
@@ -88,7 +90,7 @@ def test_math_number_all_mathjax(app, status, warning):
assert re.search(html, content, re.S)
@with_app('latex', testroot='ext-math',
@pytest.mark.sphinx('latex', testroot='ext-math',
confoverrides={'extensions': ['sphinx.ext.mathjax']})
def test_math_number_all_latex(app, status, warning):
app.builder.build_all()

View File

@@ -10,10 +10,11 @@
"""
import re
from util import with_app
import pytest
@with_app('html', testroot='ext-todo', freshenv=True,
@pytest.mark.sphinx('html', testroot='ext-todo', freshenv=True,
confoverrides={'todo_include_todos': True, 'todo_emit_warnings': True})
def test_todo(app, status, warning):
todos = []
@@ -49,7 +50,7 @@ def test_todo(app, status, warning):
assert set(todo[1].astext() for todo in todos) == set(['todo in foo', 'todo in bar'])
@with_app('html', testroot='ext-todo', freshenv=True,
@pytest.mark.sphinx('html', testroot='ext-todo', freshenv=True,
confoverrides={'todo_include_todos': False, 'todo_emit_warnings': True})
def test_todo_not_included(app, status, warning):
todos = []

View File

@@ -11,10 +11,10 @@
import re
from util import with_app
import pytest
@with_app(testroot='ext-viewcode')
@pytest.mark.sphinx(testroot='ext-viewcode')
def test_viewcode(app, status, warning):
app.builder.build_all()
@@ -32,7 +32,7 @@ def test_viewcode(app, status, warning):
assert result.count('href="_modules/spam/mod2.html#Class2"') == 2
@with_app(testroot='ext-viewcode', tags=['test_linkcode'])
@pytest.mark.sphinx(testroot='ext-viewcode', tags=['test_linkcode'])
def test_linkcode(app, status, warning):
app.builder.build(['objects'])

View File

@@ -16,8 +16,6 @@ from pygments.formatters.html import HtmlFormatter
from sphinx.highlighting import PygmentsBridge
from util import with_app
class MyLexer(RegexLexer):
name = 'testlexer'
@@ -41,7 +39,6 @@ class ComplainOnUnhighlighted(PygmentsBridge):
raise AssertionError("should highlight %r" % source)
@with_app()
def test_add_lexer(app, status, warning):
app.add_lexer('test', MyLexer())

View File

@@ -19,8 +19,9 @@ from subprocess import Popen, PIPE
from babel.messages import pofile
from six import string_types
import pytest
from util import tempdir, rootdir, path, gen_with_app, with_app, SkipTest, \
from util import tempdir, rootdir, path, gen_with_app, SkipTest, \
assert_re_search, assert_not_re_search, assert_in, assert_not_in, \
assert_startswith, assert_node, etree_parse, assert_equal
@@ -845,7 +846,7 @@ def test_references(app, status, warning):
yield assert_count(warning_expr, warnings, 0)
@with_app(buildername='dummy', testroot='image-glob', confoverrides={'language': 'xx'})
@pytest.mark.sphinx('dummy', testroot='image-glob', confoverrides={'language': 'xx'})
def test_image_glob_intl(app, status, warning):
app.builder.build_all()
@@ -886,7 +887,7 @@ def test_image_glob_intl(app, status, warning):
'image/svg+xml': 'subdir/svgimg.xx.svg'})
@with_app(buildername='dummy', testroot='image-glob',
@pytest.mark.sphinx('dummy', testroot='image-glob',
confoverrides={'language': 'xx',
'figure_language_filename': u'{root}{ext}.{language}'})
def test_image_glob_intl_using_figure_language_filename(app, status, warning):

View File

@@ -20,8 +20,9 @@ from sphinx.util import texescape
from sphinx.util.docutils import sphinx_domains
from sphinx.writers.html import HTMLWriter, SmartyPantsHTMLTranslator
from sphinx.writers.latex import LaTeXWriter, LaTeXTranslator
import pytest
from util import TestApp, with_app, assert_node
from util import TestApp, assert_node
app = settings = parser = domain_context = None
@@ -152,7 +153,7 @@ def test_latex_escaping():
r'\\href{http://example.com/~me/}{test}.*')
@with_app(buildername='dummy', testroot='prolog')
@pytest.mark.sphinx('dummy', testroot='prolog')
def test_rst_prolog(app, status, warning):
app.builder.build_all()
rst = pickle.loads((app.doctreedir / 'restructuredtext.doctree').bytes())
@@ -176,7 +177,7 @@ def test_rst_prolog(app, status, warning):
assert not md.rawsource.endswith('*Good-bye world*.\n')
@with_app(buildername='dummy', testroot='keep_warnings')
@pytest.mark.sphinx('dummy', testroot='keep_warnings')
def test_keep_warnings_is_True(app, status, warning):
app.builder.build_all()
doctree = pickle.loads((app.doctreedir / 'index.doctree').bytes())
@@ -185,7 +186,7 @@ def test_keep_warnings_is_True(app, status, warning):
assert_node(doctree[0][1], nodes.system_message)
@with_app(buildername='dummy', testroot='keep_warnings',
@pytest.mark.sphinx('dummy', testroot='keep_warnings',
confoverrides={'keep_warnings': False})
def test_keep_warnings_is_False(app, status, warning):
app.builder.build_all()
@@ -194,7 +195,7 @@ def test_keep_warnings_is_False(app, status, warning):
assert len(doctree[0]) == 1
@with_app(buildername='dummy', testroot='refonly_bullet_list')
@pytest.mark.sphinx('dummy', testroot='refonly_bullet_list')
def test_compact_refonly_bullet_list(app, status, warning):
app.builder.build_all()
doctree = pickle.loads((app.doctreedir / 'index.doctree').bytes())

View File

@@ -12,10 +12,10 @@
# adapted from an example of bibliographic metadata at
# http://docutils.sourceforge.net/docs/user/rst/demo.txt
from util import with_app
import pytest
@with_app('pseudoxml')
@pytest.mark.sphinx('pseudoxml')
def test_docinfo(app, status, warning):
"""
Inspect the 'docinfo' metadata stored in the first node of the document.

View File

@@ -15,8 +15,7 @@ from docutils.parsers import rst
from sphinx.search import IndexBuilder
from sphinx.util import jsdump
from util import with_app
import pytest
settings = parser = None
@@ -58,7 +57,7 @@ def test_wordcollector():
assert 'fermion' in ix._mapping
@with_app(testroot='ext-viewcode')
@pytest.mark.sphinx(testroot='ext-viewcode')
def test_objects_are_escaped(app, status, warning):
app.builder.build_all()
searchindex = (app.outdir / 'searchindex.js').text()
@@ -68,7 +67,7 @@ def test_objects_are_escaped(app, status, warning):
assert 'n::Array&lt;T, d&gt;' in index.get('objects').get('') # n::Array<T,d> is escaped
@with_app(testroot='search')
@pytest.mark.sphinx(testroot='search')
def test_meta_keys_are_handled_for_language_en(app, status, warning):
app.builder.build_all()
searchindex = jsload(app.outdir / 'searchindex.js')
@@ -81,7 +80,7 @@ def test_meta_keys_are_handled_for_language_en(app, status, warning):
assert not is_registered_term(searchindex, 'onlytoogerman')
@with_app(testroot='search', confoverrides={'html_search_language': 'de'})
@pytest.mark.sphinx(testroot='search', confoverrides={'html_search_language': 'de'})
def test_meta_keys_are_handled_for_language_de(app, status, warning):
app.builder.build_all()
searchindex = jsload(app.outdir / 'searchindex.js')
@@ -94,14 +93,14 @@ def test_meta_keys_are_handled_for_language_de(app, status, warning):
assert is_registered_term(searchindex, 'onlytoogerman')
@with_app(testroot='search')
@pytest.mark.sphinx(testroot='search')
def test_stemmer_does_not_remove_short_words(app, status, warning):
app.builder.build_all()
searchindex = (app.outdir / 'searchindex.js').text()
assert 'zfs' in searchindex
@with_app(testroot='search')
@pytest.mark.sphinx(testroot='search')
def test_stemmer(app, status, warning):
searchindex = jsload(app.outdir / 'searchindex.js')
print(searchindex)
@@ -109,7 +108,7 @@ def test_stemmer(app, status, warning):
assert is_registered_term(searchindex, 'intern')
@with_app(testroot='search')
@pytest.mark.sphinx(testroot='search')
def test_term_in_heading_and_section(app, status, warning):
searchindex = (app.outdir / 'searchindex.js').text()
# if search term is in the title of one doc and in the text of another
@@ -119,7 +118,7 @@ def test_term_in_heading_and_section(app, status, warning):
assert 'textinhead:0' in searchindex
@with_app(testroot='search')
@pytest.mark.sphinx(testroot='search')
def test_term_in_raw_directive(app, status, warning):
searchindex = jsload(app.outdir / 'searchindex.js')
assert not is_registered_term(searchindex, 'raw')

View File

@@ -9,10 +9,10 @@
:license: BSD, see LICENSE for details.
"""
from util import with_app
import pytest
@with_app('html', testroot='templating')
@pytest.mark.sphinx('html', testroot='templating')
def test_layout_overloading(app, status, warning):
app.builder.build_update()
@@ -21,7 +21,7 @@ def test_layout_overloading(app, status, warning):
assert '<!-- layout overloading -->' in result
@with_app('html', testroot='templating')
@pytest.mark.sphinx('html', testroot='templating')
def test_autosummary_class_template_overloading(app, status, warning):
app.builder.build_update()

View File

@@ -20,8 +20,9 @@ from sphinx.theming import Theme, ThemeError
from util import with_app, path
@with_app(confoverrides={'html_theme': 'ziptheme',
'html_theme_options.testopt': 'foo'})
@pytest.mark.sphinx(
confoverrides={'html_theme': 'ziptheme',
'html_theme_options.testopt': 'foo'})
def test_theme_api(app, status, warning):
cfg = app.config
@@ -62,7 +63,7 @@ def test_theme_api(app, status, warning):
assert not os.path.exists(themedir)
@with_app(testroot='tocdepth') # a minimal root
@pytest.mark.sphinx(testroot='tocdepth') # a minimal root
def test_js_source(app, status, warning):
# Now sphinx provides non-minified JS files for jquery.js and underscore.js
# to clarify the source of the minified files. see also #1434.
@@ -86,7 +87,7 @@ def test_js_source(app, status, warning):
assert 'Underscore.js {v}'.format(v=v) in underscore_src, msg
@with_app(testroot='double-inheriting-theme')
@pytest.mark.sphinx(testroot='double-inheriting-theme')
def test_double_inheriting_theme(make_app, app_params):
from sphinx.theming import load_theme_plugins # load original before patching

View File

@@ -8,11 +8,9 @@
:copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
import pytest
from util import with_app
@with_app(testroot='toctree-glob')
@pytest.mark.sphinx(testroot='toctree-glob')
def test_relations(app, status, warning):
app.builder.build_all()
assert app.builder.relations['index'] == [None, None, 'foo']