Organise tests into directories

This commit is contained in:
Adam Turner 2024-01-17 02:38:46 +00:00
parent 841f2bd9b7
commit 462404cb25
121 changed files with 467 additions and 442 deletions

View File

@ -510,8 +510,8 @@ select = [
]
# these tests need old ``typing`` generic aliases
"tests/test_util_typing.py" = ["UP006", "UP035"]
"tests/typing_test_data.py" = ["FA100", "UP006", "UP035"]
"tests/test_util/test_util_typing.py" = ["UP006", "UP035"]
"tests/test_util/typing_test_data.py" = ["FA100", "UP006", "UP035"]
"utils/*" = [
"T201", # whitelist ``print`` for stdout messages
@ -520,3 +520,8 @@ select = [
[lint.flake8-quotes]
inline-quotes = "single"
[lint.isort]
forced-separate = [
"tests",
]

View File

@ -19,8 +19,8 @@ if TYPE_CHECKING:
DEFAULT_ENABLED_MARKERS = [
(
'sphinx(builder, testroot=None, freshenv=False, confoverrides=None, tags=None,'
' docutilsconf=None, parallel=0): arguments to initialize the sphinx test application.'
'sphinx(builder, testroot=None, freshenv=False, confoverrides=None, tags=None, '
'docutils_conf=None, parallel=0): arguments to initialize the sphinx test application.'
),
'test_params(shared_result=...): test parameters.',
]

View File

@ -10,10 +10,8 @@ from typing import IO, TYPE_CHECKING, Any
from xml.etree import ElementTree
from docutils import nodes
from docutils.parsers.rst import directives, roles
from sphinx import application, locale
from sphinx.pycode import ModuleAnalyzer
from sphinx import application
if TYPE_CHECKING:
from io import StringIO
@ -89,14 +87,14 @@ class SphinxTestApp(application.Sphinx):
status: IO | None = None,
warning: IO | None = None,
tags: list[str] | None = None,
docutilsconf: str | None = None,
docutils_conf: str | None = None,
parallel: int = 0,
) -> None:
assert srcdir is not None
self.docutils_conf_path = srcdir / 'docutils.conf'
if docutilsconf is not None:
self.docutils_conf_path.write_text(docutilsconf, encoding='utf8')
if docutils_conf is not None:
self.docutils_conf_path.write_text(docutils_conf, encoding='utf8')
if builddir is None:
builddir = srcdir / '_build'
@ -108,35 +106,32 @@ class SphinxTestApp(application.Sphinx):
doctreedir.mkdir(parents=True, exist_ok=True)
if confoverrides is None:
confoverrides = {}
warningiserror = False
self._saved_path = sys.path.copy()
self._saved_directives = directives._directives.copy() # type: ignore[attr-defined]
self._saved_roles = roles._roles.copy() # type: ignore[attr-defined]
self._saved_nodeclasses = {v for v in dir(nodes.GenericNodeVisitor)
if v.startswith('visit_')}
try:
super().__init__(srcdir, confdir, outdir, doctreedir,
buildername, confoverrides, status, warning,
freshenv, warningiserror, tags, parallel=parallel)
super().__init__(
srcdir, confdir, outdir, doctreedir,
buildername, confoverrides, status, warning, freshenv,
warningiserror=False, tags=tags, parallel=parallel,
)
except Exception:
self.cleanup()
raise
def cleanup(self, doctrees: bool = False) -> None:
ModuleAnalyzer.cache.clear()
locale.translators.clear()
sys.path[:] = self._saved_path
sys.modules.pop('autodoc_fodder', None)
directives._directives = self._saved_directives # type: ignore[attr-defined]
roles._roles = self._saved_roles # type: ignore[attr-defined]
for method in dir(nodes.GenericNodeVisitor):
if method.startswith('visit_') and \
method not in self._saved_nodeclasses:
delattr(nodes.GenericNodeVisitor, 'visit_' + method[6:])
delattr(nodes.GenericNodeVisitor, 'depart_' + method[6:])
# ModuleAnalyzer.cache.clear()
# locale.translators.clear()
# sys.path[:] = self._saved_path
# sys.modules.pop('autodoc_fodder', None)
# directives._directives.clear() # type: ignore[attr-defined]
# roles._roles.clear() # type: ignore[attr-defined]
# for node in additional_nodes:
# delattr(nodes.GenericNodeVisitor, f'visit_{node.__name__}')
# delattr(nodes.GenericNodeVisitor, f'depart_{node.__name__}')
# delattr(nodes.SparseNodeVisitor, f'visit_{node.__name__}')
# delattr(nodes.SparseNodeVisitor, f'depart_{node.__name__}')
# additional_nodes.clear()
with contextlib.suppress(FileNotFoundError):
os.remove(self.docutils_conf_path)

View File

@ -1,11 +1,16 @@
import os
import sys
from pathlib import Path
import docutils
import pytest
from docutils import nodes
from docutils.parsers.rst import directives, roles
import sphinx
import sphinx.locale
import sphinx.pycode
from sphinx.util.docutils import additional_nodes
def _init_console(locale_dir=sphinx.locale._LOCALE_DIR, catalog='sphinx'):
@ -30,7 +35,7 @@ os.environ['SPHINX_AUTODOC_RELOAD_MODULES'] = '1'
@pytest.fixture(scope='session')
def rootdir():
return Path(__file__).parent.absolute() / 'roots'
return Path(__file__).parent.resolve() / 'roots'
def pytest_report_header(config):
@ -38,3 +43,25 @@ def pytest_report_header(config):
if hasattr(config, '_tmp_path_factory'):
header += f"\nbase tmp_path: {config._tmp_path_factory.getbasetemp()}"
return header
@pytest.fixture(autouse=True)
def _cleanup_docutils():
saved_path = sys.path
yield # run the test
sys.path[:] = saved_path
# clean up Docutils global state
directives._directives.clear() # type: ignore[attr-defined]
roles._roles.clear() # type: ignore[attr-defined]
for node in additional_nodes:
delattr(nodes.GenericNodeVisitor, f'visit_{node.__name__}')
delattr(nodes.GenericNodeVisitor, f'depart_{node.__name__}')
delattr(nodes.SparseNodeVisitor, f'visit_{node.__name__}')
delattr(nodes.SparseNodeVisitor, f'depart_{node.__name__}')
additional_nodes.clear()
# clean up Sphinx global state
sphinx.locale.translators.clear()
sphinx.pycode.ModuleAnalyzer.cache.clear()
sys.modules.pop('autodoc_fodder', None)

View File

@ -6,7 +6,7 @@ source_suffix = '.txt'
exclude_patterns = ['_build']
doctest_global_setup = '''
from tests.test_ext_doctest import record
from tests.test_extensions.test_ext_doctest import record
record('doctest_global_setup', 'body', True)
'''

View File

@ -139,7 +139,7 @@ Special directives
.. testcleanup:: *
from tests import test_ext_doctest
from tests.test_extensions import test_ext_doctest
test_ext_doctest.cleanup_call()
non-ASCII result

View File

View File

@ -3,7 +3,6 @@
import os
import shutil
from contextlib import contextmanager
from pathlib import Path
from unittest import mock
import pytest
@ -12,6 +11,8 @@ from docutils import nodes
from sphinx.cmd.build import build_main
from sphinx.errors import SphinxError
from tests.utils import TESTS_ROOT
def request_session_head(url, **kwargs):
response = mock.Mock()
@ -63,12 +64,12 @@ def test_root_doc_not_found(tmp_path, make_app):
app = make_app('dummy', srcdir=tmp_path)
with pytest.raises(SphinxError):
app.builder.build_all() # no index.rst
app.build(force_all=True) # no index.rst
@pytest.mark.sphinx(buildername='text', testroot='circular')
def test_circular_toctree(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
warnings = warning.getvalue()
assert (
'circular toctree references detected, ignoring: '
@ -80,7 +81,7 @@ def test_circular_toctree(app, status, warning):
@pytest.mark.sphinx(buildername='text', testroot='numbered-circular')
def test_numbered_circular_toctree(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
warnings = warning.getvalue()
assert (
'circular toctree references detected, ignoring: '
@ -92,7 +93,7 @@ def test_numbered_circular_toctree(app, status, warning):
@pytest.mark.sphinx(buildername='dummy', testroot='images')
def test_image_glob(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
# index.rst
doctree = app.env.get_doctree('index')
@ -155,7 +156,7 @@ def force_colors():
def test_log_no_ansi_colors(tmp_path):
with force_colors():
wfile = tmp_path / 'warnings.txt'
srcdir = Path(__file__).parent / 'roots/test-nitpicky-warnings'
srcdir = TESTS_ROOT / 'roots' / 'test-nitpicky-warnings'
argv = list(map(str, ['-b', 'html', srcdir, tmp_path, '-n', '-w', wfile]))
retcode = build_main(argv)
assert retcode == 0

View File

@ -61,7 +61,7 @@ class EPUBElementTree:
@pytest.mark.sphinx('epub', testroot='basic')
def test_build_epub(app):
app.builder.build_all()
app.build(force_all=True)
assert (app.outdir / 'mimetype').read_text(encoding='utf8') == 'application/epub+zip'
assert (app.outdir / 'META-INF' / 'container.xml').exists()
@ -278,7 +278,7 @@ def test_escaped_toc(app):
@pytest.mark.sphinx('epub', testroot='basic')
def test_epub_writing_mode(app):
# horizontal (default)
app.builder.build_all()
app.build(force_all=True)
# horizontal / page-progression-direction
opf = EPUBElementTree.fromstring((app.outdir / 'content.opf').read_text(encoding='utf8'))
@ -324,7 +324,7 @@ def test_epub_anchor_id(app):
@pytest.mark.sphinx('epub', testroot='html_assets')
def test_epub_assets(app):
app.builder.build_all()
app.build(force_all=True)
# epub_sytlesheets (same as html_css_files)
content = (app.outdir / 'index.xhtml').read_text(encoding='utf8')
@ -337,7 +337,7 @@ def test_epub_assets(app):
@pytest.mark.sphinx('epub', testroot='html_assets',
confoverrides={'epub_css_files': ['css/epub.css']})
def test_epub_css_files(app):
app.builder.build_all()
app.build(force_all=True)
# epub_css_files
content = (app.outdir / 'index.xhtml').read_text(encoding='utf8')
@ -368,7 +368,7 @@ def test_html_download_role(app, status, warning):
@pytest.mark.sphinx('epub', testroot='toctree-duplicated')
def test_duplicated_toctree_entry(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
assert 'WARNING: duplicated ToC entry found: foo.xhtml' in warning.getvalue()

View File

@ -47,7 +47,7 @@ def test_Catalog_duplicated_message():
@pytest.mark.sphinx('gettext', srcdir='root-gettext')
def test_build_gettext(app):
# Generic build; should fail only when the builder is horribly broken.
app.builder.build_all()
app.build(force_all=True)
# Do messages end up in the correct location?
# top-level documents end up in a message catalog
@ -62,7 +62,7 @@ def test_build_gettext(app):
@pytest.mark.sphinx('gettext', srcdir='root-gettext')
def test_msgfmt(app):
app.builder.build_all()
app.build(force_all=True)
(app.outdir / 'en' / 'LC_MESSAGES').mkdir(parents=True, exist_ok=True)
with chdir(app.outdir):
@ -102,7 +102,7 @@ def test_msgfmt(app):
confoverrides={'gettext_compact': False})
def test_gettext_index_entries(app):
# regression test for #976
app.builder.build(['index_entries'])
app.build(filenames=[app.srcdir / 'index_entries.txt'])
pot = (app.outdir / 'index_entries.pot').read_text(encoding='utf8')
msg_ids = list(filter(None, map(msgid_getter, pot.splitlines())))
@ -131,7 +131,7 @@ def test_gettext_index_entries(app):
def test_gettext_disable_index_entries(app):
# regression test for #976
app.env._pickled_doctree_cache.clear() # clear cache
app.builder.build(['index_entries'])
app.build(filenames=[app.srcdir / 'index_entries.txt'])
pot = (app.outdir / 'index_entries.pot').read_text(encoding='utf8')
msg_ids = list(filter(None, map(msgid_getter, pot.splitlines())))
@ -147,7 +147,7 @@ def test_gettext_disable_index_entries(app):
@pytest.mark.sphinx('gettext', testroot='intl', srcdir='gettext')
def test_gettext_template(app):
app.builder.build_all()
app.build(force_all=True)
assert (app.outdir / 'sphinx.pot').is_file()
@ -158,7 +158,7 @@ def test_gettext_template(app):
@pytest.mark.sphinx('gettext', testroot='gettext-template')
def test_gettext_template_msgid_order_in_sphinxpot(app):
app.builder.build_all()
app.build(force_all=True)
assert (app.outdir / 'sphinx.pot').is_file()
result = (app.outdir / 'sphinx.pot').read_text(encoding='utf8')
@ -175,7 +175,7 @@ def test_gettext_template_msgid_order_in_sphinxpot(app):
'gettext', srcdir='root-gettext',
confoverrides={'gettext_compact': 'documentation'})
def test_build_single_pot(app):
app.builder.build_all()
app.build(force_all=True)
assert (app.outdir / 'documentation.pot').is_file()
@ -196,7 +196,7 @@ def test_build_single_pot(app):
confoverrides={'gettext_compact': False,
'gettext_additional_targets': ['image']})
def test_gettext_prolog_epilog_substitution(app):
app.builder.build_all()
app.build(force_all=True)
assert (app.outdir / 'prolog_epilog_substitution.pot').is_file()
pot = (app.outdir / 'prolog_epilog_substitution.pot').read_text(encoding='utf8')
@ -223,7 +223,7 @@ def test_gettext_prolog_epilog_substitution(app):
'gettext_additional_targets': ['image']})
def test_gettext_prolog_epilog_substitution_excluded(app):
# regression test for #9428
app.builder.build_all()
app.build(force_all=True)
assert (app.outdir / 'prolog_epilog_substitution_excluded.pot').is_file()
pot = (app.outdir / 'prolog_epilog_substitution_excluded.pot').read_text(encoding='utf8')

View File

@ -22,22 +22,22 @@ FIGURE_CAPTION = ".//figure/figcaption/p"
ENV_WARNINGS = """\
%(root)s/autodoc_fodder.py:docstring of autodoc_fodder.MarkupError:\\d+: \
{root}/autodoc_fodder.py:docstring of autodoc_fodder.MarkupError:\\d+: \
WARNING: Explicit markup ends without a blank line; unexpected unindent.
%(root)s/index.rst:\\d+: WARNING: Encoding 'utf-8-sig' used for reading included \
file '%(root)s/wrongenc.inc' seems to be wrong, try giving an :encoding: option
%(root)s/index.rst:\\d+: WARNING: invalid single index entry ''
%(root)s/index.rst:\\d+: WARNING: image file not readable: foo.png
%(root)s/index.rst:\\d+: WARNING: download file not readable: %(root)s/nonexisting.png
%(root)s/undecodable.rst:\\d+: WARNING: undecodable source characters, replacing \
{root}/index.rst:\\d+: WARNING: Encoding 'utf-8-sig' used for reading included \
file '{root}/wrongenc.inc' seems to be wrong, try giving an :encoding: option
{root}/index.rst:\\d+: WARNING: invalid single index entry ''
{root}/index.rst:\\d+: WARNING: image file not readable: foo.png
{root}/index.rst:\\d+: WARNING: download file not readable: {root}/nonexisting.png
{root}/undecodable.rst:\\d+: WARNING: undecodable source characters, replacing \
with "\\?": b?'here: >>>(\\\\|/)xbb<<<((\\\\|/)r)?'
"""
HTML_WARNINGS = ENV_WARNINGS + """\
%(root)s/index.rst:\\d+: WARNING: unknown option: '&option'
%(root)s/index.rst:\\d+: WARNING: citation not found: missing
%(root)s/index.rst:\\d+: WARNING: a suitable image for html builder not found: foo.\\*
%(root)s/index.rst:\\d+: WARNING: Lexing literal_block ".*" as "c" resulted in an error at token: ".*". Retrying in relaxed mode.
{root}/index.rst:\\d+: WARNING: unknown option: '&option'
{root}/index.rst:\\d+: WARNING: citation not found: missing
{root}/index.rst:\\d+: WARNING: a suitable image for html builder not found: foo.\\*
{root}/index.rst:\\d+: WARNING: Lexing literal_block ".*" as "c" resulted in an error at token: ".*". Retrying in relaxed mode.
"""
@ -110,16 +110,16 @@ def check_xpath(etree, fname, path, check, be_found=True):
[node.text for node in nodes]))
@pytest.mark.sphinx('html', testroot='warnings')
@pytest.mark.sphinx('html', testroot='warnings', freshenv=True)
def test_html_warnings(app, warning):
app.build()
html_warnings = strip_escseq(re.sub(re.escape(os.sep) + '{1,2}', '/', warning.getvalue()))
html_warnings_exp = HTML_WARNINGS % {
'root': re.escape(app.srcdir.as_posix())}
assert re.match(html_warnings_exp + '$', html_warnings), \
"Warnings don't match:\n" + \
'--- Expected (regex):\n' + html_warnings_exp + \
'--- Got:\n' + html_warnings
app.build(force_all=True)
warnings = strip_escseq(re.sub(re.escape(os.sep) + '{1,2}', '/', warning.getvalue()))
warnings_exp = HTML_WARNINGS.format(root=re.escape(app.srcdir.as_posix()))
assert re.match(warnings_exp + '$', warnings), (
"Warnings don't match:\n"
+ f'--- Expected (regex):\n{warnings_exp}\n'
+ f'--- Got:\n{warnings}'
)
def test_html4_error(make_app, tmp_path):
@ -1123,7 +1123,7 @@ def test_enumerable_node(app, cached_etree_parse, expect):
@pytest.mark.sphinx('html', testroot='html_assets')
def test_html_assets(app):
app.builder.build_all()
app.build(force_all=True)
# exclude_path and its family
assert not (app.outdir / 'static' / 'index.html').exists()
@ -1178,7 +1178,7 @@ def test_assets_order(app, monkeypatch):
app.add_js_file('late.js', priority=750)
app.add_js_file('lazy.js', priority=900)
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'index.html').read_text(encoding='utf8')
# css_files
@ -1219,7 +1219,7 @@ def test_file_checksum(app):
app.add_js_file('empty.js')
app.add_js_file('https://example.com/script.js')
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'index.html').read_text(encoding='utf8')
# checksum for local files
@ -1255,7 +1255,7 @@ def test_javscript_loading_method(app):
app.add_js_file('early.js', loading_method='async')
app.add_js_file('late.js', loading_method='defer')
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'index.html').read_text(encoding='utf8')
assert '<script src="_static/normal.js"></script>' in content
@ -1265,31 +1265,31 @@ def test_javscript_loading_method(app):
@pytest.mark.sphinx('html', testroot='basic', confoverrides={'html_copy_source': False})
def test_html_copy_source(app):
app.builder.build_all()
app.build(force_all=True)
assert not (app.outdir / '_sources' / 'index.rst.txt').exists()
@pytest.mark.sphinx('html', testroot='basic', confoverrides={'html_sourcelink_suffix': '.txt'})
def test_html_sourcelink_suffix(app):
app.builder.build_all()
app.build(force_all=True)
assert (app.outdir / '_sources' / 'index.rst.txt').exists()
@pytest.mark.sphinx('html', testroot='basic', confoverrides={'html_sourcelink_suffix': '.rst'})
def test_html_sourcelink_suffix_same(app):
app.builder.build_all()
app.build(force_all=True)
assert (app.outdir / '_sources' / 'index.rst').exists()
@pytest.mark.sphinx('html', testroot='basic', confoverrides={'html_sourcelink_suffix': ''})
def test_html_sourcelink_suffix_empty(app):
app.builder.build_all()
app.build(force_all=True)
assert (app.outdir / '_sources' / 'index.rst').exists()
@pytest.mark.sphinx('html', testroot='html_entity')
def test_html_entity(app):
app.builder.build_all()
app.build(force_all=True)
valid_entities = {'amp', 'lt', 'gt', 'quot', 'apos'}
content = (app.outdir / 'index.html').read_text(encoding='utf8')
for entity in re.findall(r'&([a-z]+);', content, re.M):
@ -1298,7 +1298,7 @@ def test_html_entity(app):
@pytest.mark.sphinx('html', testroot='basic')
def test_html_inventory(app):
app.builder.build_all()
app.build(force_all=True)
with app.outdir.joinpath('objects.inv').open('rb') as f:
invdata = InventoryFile.load(f, 'https://www.google.com', posixpath.join)
@ -1333,7 +1333,7 @@ def test_html_inventory(app):
@pytest.mark.sphinx('html', testroot='images', confoverrides={'html_sourcelink_suffix': ''})
def test_html_anchor_for_figure(app):
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'index.html').read_text(encoding='utf8')
assert ('<figcaption>\n<p><span class="caption-text">The caption of pic</span>'
'<a class="headerlink" href="#id1" title="Link to this image">¶</a></p>\n</figcaption>'
@ -1342,7 +1342,7 @@ def test_html_anchor_for_figure(app):
@pytest.mark.sphinx('html', testroot='directives-raw')
def test_html_raw_directive(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'index.html').read_text(encoding='utf8')
# standard case
@ -1393,7 +1393,7 @@ def test_html_style(app, status, warning):
@pytest.mark.sphinx('html', testroot='images')
def test_html_remote_images(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'index.html').read_text(encoding='utf8')
assert ('<img alt="https://www.python.org/static/img/python-logo.png" '
@ -1403,7 +1403,7 @@ def test_html_remote_images(app, status, warning):
@pytest.mark.sphinx('html', testroot='image-escape')
def test_html_encoded_image(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'index.html').read_text(encoding='utf8')
assert ('<img alt="_images/img_%231.png" src="_images/img_%231.png" />' in result)
@ -1412,7 +1412,7 @@ def test_html_encoded_image(app, status, warning):
@pytest.mark.sphinx('html', testroot='remote-logo')
def test_html_remote_logo(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'index.html').read_text(encoding='utf8')
assert ('<img class="logo" src="https://www.python.org/static/img/python-logo.png" alt="Logo"/>' in result)
@ -1422,7 +1422,7 @@ def test_html_remote_logo(app, status, warning):
@pytest.mark.sphinx('html', testroot='local-logo')
def test_html_local_logo(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'index.html').read_text(encoding='utf8')
assert ('<img class="logo" src="_static/img.png" alt="Logo"/>' in result)
@ -1434,7 +1434,7 @@ def test_html_sidebar(app, status, warning):
ctx = {}
# default for alabaster
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'index.html').read_text(encoding='utf8')
assert ('<div class="sphinxsidebar" role="navigation" '
'aria-label="main navigation">' in result)
@ -1449,7 +1449,7 @@ def test_html_sidebar(app, status, warning):
# only relations.html
app.config.html_sidebars = {'**': ['relations.html']}
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'index.html').read_text(encoding='utf8')
assert ('<div class="sphinxsidebar" role="navigation" '
'aria-label="main navigation">' in result)
@ -1463,7 +1463,7 @@ def test_html_sidebar(app, status, warning):
# no sidebars
app.config.html_sidebars = {'**': []}
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'index.html').read_text(encoding='utf8')
assert ('<div class="sphinxsidebar" role="navigation" '
'aria-label="main navigation">' not in result)

View File

@ -19,7 +19,7 @@ from sphinx.testing.util import strip_escseq
from sphinx.util.osutil import ensuredir
from sphinx.writers.latex import LaTeXTranslator
from .test_build_html import ENV_WARNINGS
from tests.test_builders.test_build_html import ENV_WARNINGS
try:
from contextlib import chdir
@ -34,10 +34,10 @@ STYLEFILES = ['article.cls', 'fancyhdr.sty', 'titlesec.sty', 'amsmath.sty',
'booktabs.sty']
LATEX_WARNINGS = ENV_WARNINGS + """\
%(root)s/index.rst:\\d+: WARNING: unknown option: '&option'
%(root)s/index.rst:\\d+: WARNING: citation not found: missing
%(root)s/index.rst:\\d+: WARNING: a suitable image for latex builder not found: foo.\\*
%(root)s/index.rst:\\d+: WARNING: Lexing literal_block ".*" as "c" resulted in an error at token: ".*". Retrying in relaxed mode.
{root}/index.rst:\\d+: WARNING: unknown option: '&option'
{root}/index.rst:\\d+: WARNING: citation not found: missing
{root}/index.rst:\\d+: WARNING: a suitable image for latex builder not found: foo.\\*
{root}/index.rst:\\d+: WARNING: Lexing literal_block ".*" as "c" resulted in an error at token: ".*". Retrying in relaxed mode.
"""
@ -121,7 +121,7 @@ def test_build_latex_doc(app, status, warning, engine, docclass, python_maximum_
load_mappings(app)
app.builder.init()
LaTeXTranslator.ignore_missing_images = True
app.builder.build_all()
app.build(force_all=True)
# file from latex_additional_files
assert (app.outdir / 'svgimg.svg').is_file()
@ -131,7 +131,7 @@ def test_build_latex_doc(app, status, warning, engine, docclass, python_maximum_
@pytest.mark.sphinx('latex')
def test_writer(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'sphinxtests.tex').read_text(encoding='utf8')
assert ('\\begin{sphinxfigure-in-table}\n\\centering\n\\capstart\n'
@ -175,20 +175,19 @@ def test_writer(app, status, warning):
@pytest.mark.sphinx('latex', testroot='warnings', freshenv=True)
def test_latex_warnings(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
warnings = strip_escseq(re.sub(re.escape(os.sep) + '{1,2}', '/', warning.getvalue()))
warnings_exp = LATEX_WARNINGS % {
'root': re.escape(app.srcdir.as_posix())}
assert re.match(warnings_exp + '$', warnings), \
"Warnings don't match:\n" + \
'--- Expected (regex):\n' + warnings_exp + \
'--- Got:\n' + warnings
warnings_exp = LATEX_WARNINGS.format(root=re.escape(app.srcdir.as_posix()))
assert re.match(warnings_exp + '$', warnings), (
"Warnings don't match:\n"
+ f'--- Expected (regex):\n{warnings_exp}\n'
+ f'--- Got:\n{warnings}'
)
@pytest.mark.sphinx('latex', testroot='basic')
def test_latex_basic(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -203,7 +202,7 @@ def test_latex_basic(app, status, warning):
'latex_documents': [('index', 'test.tex', 'title', 'author', 'manual')],
})
def test_latex_basic_manual(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
print(result)
assert r'\def\sphinxdocclass{report}' in result
@ -215,7 +214,7 @@ def test_latex_basic_manual(app, status, warning):
'latex_documents': [('index', 'test.tex', 'title', 'author', 'howto')],
})
def test_latex_basic_howto(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
print(result)
assert r'\def\sphinxdocclass{article}' in result
@ -228,7 +227,7 @@ def test_latex_basic_howto(app, status, warning):
'latex_documents': [('index', 'test.tex', 'title', 'author', 'manual')],
})
def test_latex_basic_manual_ja(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
print(result)
assert r'\def\sphinxdocclass{ujbook}' in result
@ -241,7 +240,7 @@ def test_latex_basic_manual_ja(app, status, warning):
'latex_documents': [('index', 'test.tex', 'title', 'author', 'howto')],
})
def test_latex_basic_howto_ja(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
print(result)
assert r'\def\sphinxdocclass{ujreport}' in result
@ -250,7 +249,7 @@ def test_latex_basic_howto_ja(app, status, warning):
@pytest.mark.sphinx('latex', testroot='latex-theme')
def test_latex_theme(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
assert r'\def\sphinxdocclass{book}' in result
@ -261,7 +260,7 @@ def test_latex_theme(app, status, warning):
confoverrides={'latex_elements': {'papersize': 'b5paper',
'pointsize': '9pt'}})
def test_latex_theme_papersize(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
assert r'\def\sphinxdocclass{book}' in result
@ -272,7 +271,7 @@ def test_latex_theme_papersize(app, status, warning):
confoverrides={'latex_theme_options': {'papersize': 'b5paper',
'pointsize': '9pt'}})
def test_latex_theme_options(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
assert r'\def\sphinxdocclass{book}' in result
@ -281,7 +280,7 @@ def test_latex_theme_options(app, status, warning):
@pytest.mark.sphinx('latex', testroot='basic', confoverrides={'language': 'zh'})
def test_latex_additional_settings_for_language_code(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -291,7 +290,7 @@ def test_latex_additional_settings_for_language_code(app, status, warning):
@pytest.mark.sphinx('latex', testroot='basic', confoverrides={'language': 'el'})
def test_latex_additional_settings_for_greek(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -302,7 +301,7 @@ def test_latex_additional_settings_for_greek(app, status, warning):
@pytest.mark.sphinx('latex', testroot='latex-title')
def test_latex_title_after_admonitions(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -313,7 +312,7 @@ def test_latex_title_after_admonitions(app, status, warning):
@pytest.mark.sphinx('latex', testroot='basic',
confoverrides={'release': '1.0_0'})
def test_latex_release(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -325,7 +324,7 @@ def test_latex_release(app, status, warning):
@pytest.mark.sphinx('latex', testroot='numfig',
confoverrides={'numfig': True})
def test_numref(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -367,7 +366,7 @@ def test_numref(app, status, warning):
'code-block': 'Code-%s',
'section': 'SECTION-%s'}})
def test_numref_with_prefix1(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -415,7 +414,7 @@ def test_numref_with_prefix1(app, status, warning):
'code-block': 'Code-%s | ',
'section': 'SECTION_%s_'}})
def test_numref_with_prefix2(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -491,7 +490,7 @@ def test_numref_with_language_ja(app, status, warning):
@pytest.mark.sphinx('latex', testroot='latex-numfig')
def test_latex_obey_numfig_is_false(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'SphinxManual.tex').read_text(encoding='utf8')
assert '\\usepackage{sphinx}' in result
@ -504,7 +503,7 @@ def test_latex_obey_numfig_is_false(app, status, warning):
'latex', testroot='latex-numfig',
confoverrides={'numfig': True, 'numfig_secnum_depth': 0})
def test_latex_obey_numfig_secnum_depth_is_zero(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'SphinxManual.tex').read_text(encoding='utf8')
assert '\\usepackage[,nonumfigreset,mathnumfig]{sphinx}' in result
@ -517,7 +516,7 @@ def test_latex_obey_numfig_secnum_depth_is_zero(app, status, warning):
'latex', testroot='latex-numfig',
confoverrides={'numfig': True, 'numfig_secnum_depth': 2})
def test_latex_obey_numfig_secnum_depth_is_two(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'SphinxManual.tex').read_text(encoding='utf8')
assert '\\usepackage[,numfigreset=2,mathnumfig]{sphinx}' in result
@ -530,7 +529,7 @@ def test_latex_obey_numfig_secnum_depth_is_two(app, status, warning):
'latex', testroot='latex-numfig',
confoverrides={'numfig': True, 'math_numfig': False})
def test_latex_obey_numfig_but_math_numfig_false(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'SphinxManual.tex').read_text(encoding='utf8')
assert '\\usepackage[,numfigreset=1]{sphinx}' in result
@ -543,7 +542,7 @@ def test_latex_obey_numfig_but_math_numfig_false(app, status, warning):
def test_latex_add_latex_package(app, status, warning):
app.add_latex_package('foo')
app.add_latex_package('bar', 'baz')
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
assert '\\usepackage{foo}' in result
assert '\\usepackage[baz]{bar}' in result
@ -551,7 +550,7 @@ def test_latex_add_latex_package(app, status, warning):
@pytest.mark.sphinx('latex', testroot='latex-babel')
def test_babel_with_no_language_settings(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -576,7 +575,7 @@ def test_babel_with_no_language_settings(app, status, warning):
'latex', testroot='latex-babel',
confoverrides={'language': 'de'})
def test_babel_with_language_de(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -601,7 +600,7 @@ def test_babel_with_language_de(app, status, warning):
'latex', testroot='latex-babel',
confoverrides={'language': 'ru'})
def test_babel_with_language_ru(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -626,7 +625,7 @@ def test_babel_with_language_ru(app, status, warning):
'latex', testroot='latex-babel',
confoverrides={'language': 'tr'})
def test_babel_with_language_tr(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -651,7 +650,7 @@ def test_babel_with_language_tr(app, status, warning):
'latex', testroot='latex-babel',
confoverrides={'language': 'ja'})
def test_babel_with_language_ja(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -675,7 +674,7 @@ def test_babel_with_language_ja(app, status, warning):
'latex', testroot='latex-babel',
confoverrides={'language': 'unknown'})
def test_babel_with_unknown_language(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -702,7 +701,7 @@ def test_babel_with_unknown_language(app, status, warning):
'latex', testroot='latex-babel',
confoverrides={'language': 'de', 'latex_engine': 'lualatex'})
def test_polyglossia_with_language_de(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -728,7 +727,7 @@ def test_polyglossia_with_language_de(app, status, warning):
'latex', testroot='latex-babel',
confoverrides={'language': 'de-1901', 'latex_engine': 'lualatex'})
def test_polyglossia_with_language_de_1901(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -752,7 +751,7 @@ def test_polyglossia_with_language_de_1901(app, status, warning):
@pytest.mark.sphinx('latex')
def test_footnote(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'sphinxtests.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -781,7 +780,7 @@ def test_footnote(app, status, warning):
@pytest.mark.sphinx('latex', testroot='footnotes')
def test_reference_in_caption_and_codeblock_in_footnote(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -821,7 +820,7 @@ def test_reference_in_caption_and_codeblock_in_footnote(app, status, warning):
@pytest.mark.sphinx('latex', testroot='footnotes')
def test_footnote_referred_multiple_times(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -843,7 +842,7 @@ def test_footnote_referred_multiple_times(app, status, warning):
'latex', testroot='footnotes',
confoverrides={'latex_show_urls': 'inline'})
def test_latex_show_urls_is_inline(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -900,7 +899,7 @@ def test_latex_show_urls_is_inline(app, status, warning):
'latex', testroot='footnotes',
confoverrides={'latex_show_urls': 'footnote'})
def test_latex_show_urls_is_footnote(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -962,7 +961,7 @@ def test_latex_show_urls_is_footnote(app, status, warning):
'latex', testroot='footnotes',
confoverrides={'latex_show_urls': 'no'})
def test_latex_show_urls_is_no(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -1017,7 +1016,7 @@ def test_latex_show_urls_footnote_and_substitutions(app, status, warning):
@pytest.mark.sphinx('latex', testroot='image-in-section')
def test_image_in_section(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -1035,12 +1034,12 @@ def test_image_in_section(app, status, warning):
confoverrides={'latex_logo': 'notfound.jpg'})
def test_latex_logo_if_not_found(app, status, warning):
with pytest.raises(SphinxError):
app.builder.build_all()
app.build(force_all=True)
@pytest.mark.sphinx('latex', testroot='toctree-maxdepth')
def test_toctree_maxdepth_manual(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -1057,7 +1056,7 @@ def test_toctree_maxdepth_manual(app, status, warning):
'Georg Brandl', 'howto'),
]})
def test_toctree_maxdepth_howto(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -1071,7 +1070,7 @@ def test_toctree_maxdepth_howto(app, status, warning):
'latex', testroot='toctree-maxdepth',
confoverrides={'root_doc': 'foo'})
def test_toctree_not_found(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -1085,7 +1084,7 @@ def test_toctree_not_found(app, status, warning):
'latex', testroot='toctree-maxdepth',
confoverrides={'root_doc': 'bar'})
def test_toctree_without_maxdepth(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -1098,7 +1097,7 @@ def test_toctree_without_maxdepth(app, status, warning):
'latex', testroot='toctree-maxdepth',
confoverrides={'root_doc': 'qux'})
def test_toctree_with_deeper_maxdepth(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -1111,7 +1110,7 @@ def test_toctree_with_deeper_maxdepth(app, status, warning):
'latex', testroot='toctree-maxdepth',
confoverrides={'latex_toplevel_sectioning': None})
def test_latex_toplevel_sectioning_is_None(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -1123,7 +1122,7 @@ def test_latex_toplevel_sectioning_is_None(app, status, warning):
'latex', testroot='toctree-maxdepth',
confoverrides={'latex_toplevel_sectioning': 'part'})
def test_latex_toplevel_sectioning_is_part(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -1141,7 +1140,7 @@ def test_latex_toplevel_sectioning_is_part(app, status, warning):
'Georg Brandl', 'howto'),
]})
def test_latex_toplevel_sectioning_is_part_with_howto(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -1155,7 +1154,7 @@ def test_latex_toplevel_sectioning_is_part_with_howto(app, status, warning):
'latex', testroot='toctree-maxdepth',
confoverrides={'latex_toplevel_sectioning': 'chapter'})
def test_latex_toplevel_sectioning_is_chapter(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -1171,7 +1170,7 @@ def test_latex_toplevel_sectioning_is_chapter(app, status, warning):
'Georg Brandl', 'howto'),
]})
def test_latex_toplevel_sectioning_is_chapter_with_howto(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -1183,7 +1182,7 @@ def test_latex_toplevel_sectioning_is_chapter_with_howto(app, status, warning):
'latex', testroot='toctree-maxdepth',
confoverrides={'latex_toplevel_sectioning': 'section'})
def test_latex_toplevel_sectioning_is_section(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -1194,7 +1193,7 @@ def test_latex_toplevel_sectioning_is_section(app, status, warning):
@skip_if_stylefiles_notfound
@pytest.mark.sphinx('latex', testroot='maxlistdepth')
def test_maxlistdepth_at_ten(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
print(status.getvalue())
@ -1206,7 +1205,7 @@ def test_maxlistdepth_at_ten(app, status, warning):
confoverrides={'latex_table_style': []})
@pytest.mark.test_params(shared_result='latex-table')
def test_latex_table_tabulars(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
tables = {}
for chap in re.split(r'\\(?:section|chapter){', result)[1:]:
@ -1277,7 +1276,7 @@ def test_latex_table_tabulars(app, status, warning):
confoverrides={'latex_table_style': []})
@pytest.mark.test_params(shared_result='latex-table')
def test_latex_table_longtable(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
tables = {}
for chap in re.split(r'\\(?:section|chapter){', result)[1:]:
@ -1338,7 +1337,7 @@ def test_latex_table_longtable(app, status, warning):
confoverrides={'latex_table_style': []})
@pytest.mark.test_params(shared_result='latex-table')
def test_latex_table_complex_tables(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
tables = {}
for chap in re.split(r'\\(?:section|renewcommand){', result)[1:]:
@ -1368,7 +1367,7 @@ def test_latex_table_complex_tables(app, status, warning):
@pytest.mark.sphinx('latex', testroot='latex-table')
def test_latex_table_with_booktabs_and_colorrows(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
assert r'\PassOptionsToPackage{booktabs}{sphinx}' in result
assert r'\PassOptionsToPackage{colorrows}{sphinx}' in result
@ -1384,7 +1383,7 @@ def test_latex_table_with_booktabs_and_colorrows(app, status, warning):
@pytest.mark.sphinx('latex', testroot='latex-table',
confoverrides={'templates_path': ['_mytemplates/latex']})
def test_latex_table_custom_template_caseA(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
assert 'SALUT LES COPAINS' in result
@ -1392,7 +1391,7 @@ def test_latex_table_custom_template_caseA(app, status, warning):
@pytest.mark.sphinx('latex', testroot='latex-table',
confoverrides={'templates_path': ['_mytemplates']})
def test_latex_table_custom_template_caseB(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
assert 'SALUT LES COPAINS' not in result
@ -1400,14 +1399,14 @@ def test_latex_table_custom_template_caseB(app, status, warning):
@pytest.mark.sphinx('latex', testroot='latex-table')
@pytest.mark.test_params(shared_result='latex-table')
def test_latex_table_custom_template_caseC(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
assert 'SALUT LES COPAINS' not in result
@pytest.mark.sphinx('latex', testroot='directives-raw')
def test_latex_raw_directive(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
# standard case
@ -1422,7 +1421,7 @@ def test_latex_raw_directive(app, status, warning):
@pytest.mark.sphinx('latex', testroot='images')
def test_latex_images(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
@ -1446,7 +1445,7 @@ def test_latex_images(app, status, warning):
@pytest.mark.sphinx('latex', testroot='latex-index')
def test_latex_index(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
assert ('A \\index{famous@\\spxentry{famous}}famous '
@ -1460,7 +1459,7 @@ def test_latex_index(app, status, warning):
@pytest.mark.sphinx('latex', testroot='latex-equations')
def test_latex_equations(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
expected = (app.srcdir / 'expects' / 'latex-equations.tex').read_text(encoding='utf8').strip()
@ -1470,7 +1469,7 @@ def test_latex_equations(app, status, warning):
@pytest.mark.sphinx('latex', testroot='image-in-parsed-literal')
def test_latex_image_in_parsed_literal(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
assert ('{\\sphinxunactivateextrasandspace \\raisebox{-0.5\\height}'
@ -1480,7 +1479,7 @@ def test_latex_image_in_parsed_literal(app, status, warning):
@pytest.mark.sphinx('latex', testroot='nested-enumerated-list')
def test_latex_nested_enumerated_list(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
assert ('\\sphinxsetlistlabels{\\arabic}{enumi}{enumii}{}{.}%\n'
@ -1497,7 +1496,7 @@ def test_latex_nested_enumerated_list(app, status, warning):
@pytest.mark.sphinx('latex', testroot='footnotes')
def test_latex_thebibliography(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
@ -1510,7 +1509,7 @@ def test_latex_thebibliography(app, status, warning):
@pytest.mark.sphinx('latex', testroot='glossary')
def test_latex_glossary(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
assert (r'\sphinxlineitem{ähnlich\index{ähnlich@\spxentry{ähnlich}|spxpagem}'
@ -1534,7 +1533,7 @@ def test_latex_glossary(app, status, warning):
@pytest.mark.sphinx('latex', testroot='latex-labels')
def test_latex_labels(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
@ -1583,7 +1582,7 @@ def test_latex_labels(app, status, warning):
@pytest.mark.sphinx('latex', testroot='latex-figure-in-admonition')
def test_latex_figure_in_admonition(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
assert r'\begin{figure}[H]' in result
@ -1605,7 +1604,7 @@ def test_default_latex_documents():
@skip_if_stylefiles_notfound
@pytest.mark.sphinx('latex', testroot='latex-includegraphics')
def test_includegraphics_oversized(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
print(status.getvalue())
print(warning.getvalue())
compile_latex_document(app)
@ -1613,7 +1612,7 @@ def test_includegraphics_oversized(app, status, warning):
@pytest.mark.sphinx('latex', testroot='index_on_title')
def test_index_on_title(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
assert ('\\chapter{Test for index in top level title}\n'
'\\label{\\detokenize{contents:test-for-index-in-top-level-title}}'
@ -1624,7 +1623,7 @@ def test_index_on_title(app, status, warning):
@pytest.mark.sphinx('latex', testroot='latex-unicode',
confoverrides={'latex_engine': 'pdflatex'})
def test_texescape_for_non_unicode_supported_engine(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
assert 'script small e: e' in result
@ -1636,7 +1635,7 @@ def test_texescape_for_non_unicode_supported_engine(app, status, warning):
@pytest.mark.sphinx('latex', testroot='latex-unicode',
confoverrides={'latex_engine': 'xelatex'})
def test_texescape_for_unicode_supported_engine(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(result)
assert 'script small e: e' in result
@ -1648,20 +1647,20 @@ def test_texescape_for_unicode_supported_engine(app, status, warning):
@pytest.mark.sphinx('latex', testroot='basic',
confoverrides={'latex_elements': {'extrapackages': r'\usepackage{foo}'}})
def test_latex_elements_extrapackages(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
assert r'\usepackage{foo}' in result
@pytest.mark.sphinx('latex', testroot='nested-tables')
def test_latex_nested_tables(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
assert warning.getvalue() == ''
@pytest.mark.sphinx('latex', testroot='latex-container')
def test_latex_container(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
assert r'\begin{sphinxuseclass}{classname}' in result
assert r'\end{sphinxuseclass}' in result
@ -1744,7 +1743,7 @@ def test_duplicated_labels_before_module(app, status, warning):
@pytest.mark.sphinx('latex', testroot='domain-py-python_maximum_signature_line_length',
confoverrides={'python_maximum_signature_line_length': 23})
def test_one_parameter_per_line(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
# TODO: should these asserts check presence or absence of a final \sphinxparamcomma?

View File

@ -10,7 +10,6 @@ import textwrap
import time
import wsgiref.handlers
from base64 import b64encode
from os import path
from queue import Queue
from unittest import mock
@ -28,10 +27,9 @@ from sphinx.builders.linkcheck import (
from sphinx.testing.util import strip_escseq
from sphinx.util import requests
from .utils import CERT_FILE, http_server, https_server
from tests.utils import CERT_FILE, http_server, https_server
ts_re = re.compile(r".*\[(?P<ts>.*)\].*")
SPHINX_DOCS_INDEX = path.abspath(path.join(__file__, "..", "roots", "test-linkcheck", "sphinx-docs-index.html"))
class DefaultsHandler(http.server.BaseHTTPRequestHandler):

View File

@ -9,7 +9,7 @@ from sphinx.config import Config
@pytest.mark.sphinx('man')
def test_all(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
assert (app.outdir / 'sphinxtests.1').exists()
content = (app.outdir / 'sphinxtests.1').read_text(encoding='utf8')
@ -34,7 +34,7 @@ def test_all(app, status, warning):
@pytest.mark.sphinx('man', testroot='basic',
confoverrides={'man_pages': [('index', 'title', None, [], 1)]})
def test_man_pages_empty_description(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'title.1').read_text(encoding='utf8')
assert r'title \-' not in content
@ -49,7 +49,7 @@ def test_man_make_section_directory(app, status, warning):
@pytest.mark.sphinx('man', testroot='directive-code')
def test_captioned_code_block(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'python.1').read_text(encoding='utf8')
if docutils.__version_info__[:2] < (0, 21):

View File

@ -15,33 +15,33 @@ from sphinx.testing.util import strip_escseq
from sphinx.util.docutils import new_document
from sphinx.writers.texinfo import TexinfoTranslator
from .test_build_html import ENV_WARNINGS
from tests.test_builders.test_build_html import ENV_WARNINGS
TEXINFO_WARNINGS = ENV_WARNINGS + """\
%(root)s/index.rst:\\d+: WARNING: unknown option: '&option'
%(root)s/index.rst:\\d+: WARNING: citation not found: missing
%(root)s/index.rst:\\d+: WARNING: a suitable image for texinfo builder not found: foo.\\*
%(root)s/index.rst:\\d+: WARNING: a suitable image for texinfo builder not found: \
{root}/index.rst:\\d+: WARNING: unknown option: '&option'
{root}/index.rst:\\d+: WARNING: citation not found: missing
{root}/index.rst:\\d+: WARNING: a suitable image for texinfo builder not found: foo.\\*
{root}/index.rst:\\d+: WARNING: a suitable image for texinfo builder not found: \
\\['application/pdf', 'image/svg\\+xml'\\] \\(svgimg.\\*\\)
"""
@pytest.mark.sphinx('texinfo', testroot='warnings', freshenv=True)
def test_texinfo_warnings(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
warnings = strip_escseq(re.sub(re.escape(os.sep) + '{1,2}', '/', warning.getvalue()))
warnings_exp = TEXINFO_WARNINGS % {
'root': re.escape(app.srcdir.as_posix())}
assert re.match(warnings_exp + '$', warnings), \
"Warnings don't match:\n" + \
'--- Expected (regex):\n' + warnings_exp + \
'--- Got:\n' + warnings
warnings_exp = TEXINFO_WARNINGS.format(root=re.escape(app.srcdir.as_posix()))
assert re.match(warnings_exp + '$', warnings), (
"Warnings don't match:\n"
+ f'--- Expected (regex):\n{warnings_exp}\n'
+ f'--- Got:\n{warnings}'
)
@pytest.mark.sphinx('texinfo')
def test_texinfo(app, status, warning):
TexinfoTranslator.ignore_missing_images = True
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'sphinxtests.texi').read_text(encoding='utf8')
assert ('@anchor{markup doc}@anchor{11}'
'@anchor{markup id1}@anchor{12}'
@ -71,7 +71,7 @@ def test_texinfo_rubric(app, status, warning):
@pytest.mark.sphinx('texinfo', testroot='markup-citation')
def test_texinfo_citation(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
output = (app.outdir / 'python.texi').read_text(encoding='utf8')
assert 'This is a citation ref; @ref{1,,[CITE1]} and @ref{2,,[CITE2]}.' in output
@ -109,7 +109,7 @@ def test_texinfo_escape_id(app, status, warning):
@pytest.mark.sphinx('texinfo', testroot='footnotes')
def test_texinfo_footnote(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
output = (app.outdir / 'python.texi').read_text(encoding='utf8')
assert 'First footnote: @footnote{\nFirst\n}' in output
@ -117,13 +117,13 @@ def test_texinfo_footnote(app, status, warning):
@pytest.mark.sphinx('texinfo')
def test_texinfo_xrefs(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
output = (app.outdir / 'sphinxtests.texi').read_text(encoding='utf8')
assert re.search(r'@ref{\w+,,--plugin\.option}', output)
# Now rebuild it without xrefs
app.config.texinfo_cross_references = False
app.builder.build_all()
app.build(force_all=True)
output = (app.outdir / 'sphinxtests.texi').read_text(encoding='utf8')
assert not re.search(r'@ref{\w+,,--plugin\.option}', output)
assert 'Link to perl +p, --ObjC++, --plugin.option, create-auth-token, arg and -j' in output

View File

@ -17,7 +17,7 @@ def with_text_app(*args, **kw):
@with_text_app()
def test_maxwitdh_with_prefix(app, status, warning):
app.builder.build_update()
app.build()
result = (app.outdir / 'maxwidth.txt').read_text(encoding='utf8')
lines = result.splitlines()
@ -40,7 +40,7 @@ def test_maxwitdh_with_prefix(app, status, warning):
@with_text_app()
def test_lineblock(app, status, warning):
# regression test for #1109: need empty line after line block
app.builder.build_update()
app.build()
result = (app.outdir / 'lineblock.txt').read_text(encoding='utf8')
expect = (
"* one\n"
@ -55,7 +55,7 @@ def test_lineblock(app, status, warning):
@with_text_app()
def test_nonascii_title_line(app, status, warning):
app.builder.build_update()
app.build()
result = (app.outdir / 'nonascii_title.txt').read_text(encoding='utf8')
expect_underline = '*********'
result_underline = result.splitlines()[1].strip()
@ -64,7 +64,7 @@ def test_nonascii_title_line(app, status, warning):
@with_text_app()
def test_nonascii_table(app, status, warning):
app.builder.build_update()
app.build()
result = (app.outdir / 'nonascii_table.txt').read_text(encoding='utf8')
lines = [line.strip() for line in result.splitlines() if line.strip()]
line_widths = [column_width(line) for line in lines]
@ -73,7 +73,7 @@ def test_nonascii_table(app, status, warning):
@with_text_app()
def test_nonascii_maxwidth(app, status, warning):
app.builder.build_update()
app.build()
result = (app.outdir / 'nonascii_maxwidth.txt').read_text(encoding='utf8')
lines = [line.strip() for line in result.splitlines() if line.strip()]
line_widths = [column_width(line) for line in lines]
@ -117,7 +117,7 @@ def test_table_cell():
@with_text_app()
def test_table_with_empty_cell(app, status, warning):
app.builder.build_update()
app.build()
result = (app.outdir / 'table.txt').read_text(encoding='utf8')
lines = [line.strip() for line in result.splitlines() if line.strip()]
assert lines[0] == "+-------+-------+"
@ -131,7 +131,7 @@ def test_table_with_empty_cell(app, status, warning):
@with_text_app()
def test_table_with_rowspan(app, status, warning):
app.builder.build_update()
app.build()
result = (app.outdir / 'table_rowspan.txt').read_text(encoding='utf8')
lines = [line.strip() for line in result.splitlines() if line.strip()]
assert lines[0] == "+-------+-------+"
@ -145,7 +145,7 @@ def test_table_with_rowspan(app, status, warning):
@with_text_app()
def test_table_with_colspan(app, status, warning):
app.builder.build_update()
app.build()
result = (app.outdir / 'table_colspan.txt').read_text(encoding='utf8')
lines = [line.strip() for line in result.splitlines() if line.strip()]
assert lines[0] == "+-------+-------+"
@ -159,7 +159,7 @@ def test_table_with_colspan(app, status, warning):
@with_text_app()
def test_table_with_colspan_left(app, status, warning):
app.builder.build_update()
app.build()
result = (app.outdir / 'table_colspan_left.txt').read_text(encoding='utf8')
lines = [line.strip() for line in result.splitlines() if line.strip()]
assert lines[0] == "+-------+-------+"
@ -173,7 +173,7 @@ def test_table_with_colspan_left(app, status, warning):
@with_text_app()
def test_table_with_colspan_and_rowspan(app, status, warning):
app.builder.build_update()
app.build()
result = (app.outdir / 'table_colspan_and_rowspan.txt').read_text(encoding='utf8')
lines = [line.strip() for line in result.splitlines() if line.strip()]
assert result
@ -188,7 +188,7 @@ def test_table_with_colspan_and_rowspan(app, status, warning):
@with_text_app()
def test_list_items_in_admonition(app, status, warning):
app.builder.build_update()
app.build()
result = (app.outdir / 'listitems.txt').read_text(encoding='utf8')
lines = [line.rstrip() for line in result.splitlines()]
assert lines[0] == "See also:"
@ -200,7 +200,7 @@ def test_list_items_in_admonition(app, status, warning):
@with_text_app()
def test_secnums(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
index = (app.outdir / 'index.txt').read_text(encoding='utf8')
lines = index.splitlines()
assert lines[0] == "* 1. Section A"
@ -226,7 +226,7 @@ def test_secnums(app, status, warning):
assert doc2 == expect
app.config.text_secnumber_suffix = " "
app.builder.build_all()
app.build(force_all=True)
index = (app.outdir / 'index.txt').read_text(encoding='utf8')
lines = index.splitlines()
assert lines[0] == "* 1 Section A"
@ -252,7 +252,7 @@ def test_secnums(app, status, warning):
assert doc2 == expect
app.config.text_add_secnumbers = False
app.builder.build_all()
app.build(force_all=True)
index = (app.outdir / 'index.txt').read_text(encoding='utf8')
lines = index.splitlines()
assert lines[0] == "* Section A"

View File

View File

@ -366,7 +366,7 @@ nitpick_warnings = [
@pytest.mark.sphinx(testroot='nitpicky-warnings')
def test_nitpick_base(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
warning = warning.getvalue().strip().split('\n')
assert len(warning) == len(nitpick_warnings)
@ -383,7 +383,7 @@ def test_nitpick_base(app, status, warning):
},
})
def test_nitpick_ignore(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
assert not len(warning.getvalue().strip())
@ -394,7 +394,7 @@ def test_nitpick_ignore(app, status, warning):
],
})
def test_nitpick_ignore_regex1(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
assert not len(warning.getvalue().strip())
@ -405,7 +405,7 @@ def test_nitpick_ignore_regex1(app, status, warning):
],
})
def test_nitpick_ignore_regex2(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
assert not len(warning.getvalue().strip())
@ -422,7 +422,7 @@ def test_nitpick_ignore_regex2(app, status, warning):
],
})
def test_nitpick_ignore_regex_fullmatch(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
warning = warning.getvalue().strip().split('\n')
assert len(warning) == len(nitpick_warnings)
@ -504,7 +504,7 @@ def source_date_year(request, monkeypatch):
@pytest.mark.sphinx(testroot='copyright-multiline')
def test_multi_line_copyright(source_date_year, app, monkeypatch):
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'index.html').read_text(encoding='utf-8')

View File

View File

@ -295,7 +295,7 @@ def test_LiteralIncludeReader_diff(testroot, literal_inc_path):
@pytest.mark.sphinx('xml', testroot='directive-code')
def test_code_block(app, status, warning):
app.builder.build('index')
app.build(filenames=[app.srcdir / 'index.rst'])
et = etree_parse(app.outdir / 'index.xml')
secs = et.findall('./section/section')
code_block = secs[0].findall('literal_block')
@ -311,13 +311,13 @@ def test_code_block(app, status, warning):
@pytest.mark.sphinx('html', testroot='directive-code')
def test_force_option(app, status, warning):
app.builder.build(['force'])
app.build(filenames=[app.srcdir / 'force.rst'])
assert 'force.rst' not in warning.getvalue()
@pytest.mark.sphinx('html', testroot='directive-code')
def test_code_block_caption_html(app, status, warning):
app.builder.build(['caption'])
app.build(filenames=[app.srcdir / 'caption.rst'])
html = (app.outdir / 'caption.html').read_text(encoding='utf8')
caption = ('<div class="code-block-caption">'
'<span class="caption-number">Listing 1 </span>'
@ -329,7 +329,7 @@ def test_code_block_caption_html(app, status, warning):
@pytest.mark.sphinx('latex', testroot='directive-code')
def test_code_block_caption_latex(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
latex = (app.outdir / 'python.tex').read_text(encoding='utf8')
caption = '\\sphinxSetupCaptionForVerbatim{caption \\sphinxstyleemphasis{test} rb}'
label = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:id1}}}'
@ -342,7 +342,7 @@ def test_code_block_caption_latex(app, status, warning):
@pytest.mark.sphinx('latex', testroot='directive-code')
def test_code_block_namedlink_latex(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
latex = (app.outdir / 'python.tex').read_text(encoding='utf8')
label1 = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:name-test-rb}}}'
link1 = '\\hyperref[\\detokenize{caption:name-test-rb}]'\
@ -359,7 +359,7 @@ def test_code_block_namedlink_latex(app, status, warning):
@pytest.mark.sphinx('latex', testroot='directive-code')
def test_code_block_emphasize_latex(app, status, warning):
app.builder.build(['emphasize'])
app.build(filenames=[app.srcdir / 'emphasize.rst'])
latex = (app.outdir / 'python.tex').read_text(encoding='utf8').replace('\r\n', '\n')
includes = '\\fvset{hllines={, 5, 6, 13, 14, 15, 24, 25, 26,}}%\n'
assert includes in latex
@ -369,7 +369,7 @@ def test_code_block_emphasize_latex(app, status, warning):
@pytest.mark.sphinx('xml', testroot='directive-code')
def test_literal_include(app, status, warning):
app.builder.build(['index'])
app.build(filenames=[app.srcdir / 'index.rst'])
et = etree_parse(app.outdir / 'index.xml')
secs = et.findall('./section/section')
literal_include = secs[1].findall('literal_block')
@ -381,7 +381,7 @@ def test_literal_include(app, status, warning):
@pytest.mark.sphinx('xml', testroot='directive-code')
def test_literal_include_block_start_with_comment_or_brank(app, status, warning):
app.builder.build(['python'])
app.build(filenames=[app.srcdir / 'python.rst'])
et = etree_parse(app.outdir / 'python.xml')
secs = et.findall('./section/section')
literal_include = secs[0].findall('literal_block')
@ -405,7 +405,7 @@ def test_literal_include_block_start_with_comment_or_brank(app, status, warning)
@pytest.mark.sphinx('html', testroot='directive-code')
def test_literal_include_linenos(app, status, warning):
app.builder.build(['linenos'])
app.build(filenames=[app.srcdir / 'linenos.rst'])
html = (app.outdir / 'linenos.html').read_text(encoding='utf8')
# :linenos:
@ -423,7 +423,7 @@ def test_literal_include_linenos(app, status, warning):
@pytest.mark.sphinx('latex', testroot='directive-code')
def test_literalinclude_file_whole_of_emptyline(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
latex = (app.outdir / 'python.tex').read_text(encoding='utf8').replace('\r\n', '\n')
includes = (
'\\begin{sphinxVerbatim}'
@ -437,7 +437,7 @@ def test_literalinclude_file_whole_of_emptyline(app, status, warning):
@pytest.mark.sphinx('html', testroot='directive-code')
def test_literalinclude_caption_html(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
html = (app.outdir / 'caption.html').read_text(encoding='utf8')
caption = ('<div class="code-block-caption">'
'<span class="caption-number">Listing 2 </span>'
@ -449,7 +449,7 @@ def test_literalinclude_caption_html(app, status, warning):
@pytest.mark.sphinx('latex', testroot='directive-code')
def test_literalinclude_caption_latex(app, status, warning):
app.builder.build('index')
app.build(filenames='index')
latex = (app.outdir / 'python.tex').read_text(encoding='utf8')
caption = '\\sphinxSetupCaptionForVerbatim{caption \\sphinxstylestrong{test} py}'
label = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:id2}}}'
@ -462,7 +462,7 @@ def test_literalinclude_caption_latex(app, status, warning):
@pytest.mark.sphinx('latex', testroot='directive-code')
def test_literalinclude_namedlink_latex(app, status, warning):
app.builder.build('index')
app.build(filenames='index')
latex = (app.outdir / 'python.tex').read_text(encoding='utf8')
label1 = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:name-test-py}}}'
link1 = '\\hyperref[\\detokenize{caption:name-test-py}]'\
@ -479,7 +479,7 @@ def test_literalinclude_namedlink_latex(app, status, warning):
@pytest.mark.sphinx('xml', testroot='directive-code')
def test_literalinclude_classes(app, status, warning):
app.builder.build(['classes'])
app.build(filenames=[app.srcdir / 'classes.rst'])
et = etree_parse(app.outdir / 'classes.xml')
secs = et.findall('./section/section')
@ -496,7 +496,7 @@ def test_literalinclude_classes(app, status, warning):
@pytest.mark.sphinx('xml', testroot='directive-code')
def test_literalinclude_pydecorators(app, status, warning):
app.builder.build(['py-decorators'])
app.build(filenames=[app.srcdir / 'py-decorators.rst'])
et = etree_parse(app.outdir / 'py-decorators.xml')
secs = et.findall('./section/section')
@ -537,7 +537,7 @@ def test_literalinclude_pydecorators(app, status, warning):
@pytest.mark.sphinx('dummy', testroot='directive-code')
def test_code_block_highlighted(app, status, warning):
app.builder.build(['highlight'])
app.build(filenames=[app.srcdir / 'highlight.rst'])
doctree = app.env.get_doctree('highlight')
codeblocks = list(doctree.findall(nodes.literal_block))
@ -549,7 +549,7 @@ def test_code_block_highlighted(app, status, warning):
@pytest.mark.sphinx('html', testroot='directive-code')
def test_linenothreshold(app, status, warning):
app.builder.build(['linenothreshold'])
app.build(filenames=[app.srcdir / 'linenothreshold.rst'])
html = (app.outdir / 'linenothreshold.html').read_text(encoding='utf8')
# code-block using linenothreshold
@ -570,7 +570,7 @@ def test_linenothreshold(app, status, warning):
@pytest.mark.sphinx('dummy', testroot='directive-code')
def test_code_block_dedent(app, status, warning):
app.builder.build(['dedent'])
app.build(filenames=[app.srcdir / 'dedent.rst'])
doctree = app.env.get_doctree('dedent')
codeblocks = list(doctree.findall(nodes.literal_block))
# Note: comparison string should not have newlines at the beginning or end

View File

@ -34,7 +34,7 @@ def test_sectioning(app, status, warning):
'Unnumbered section: %r' % subsect[0]
testsects(prefix + str(i + 1) + '.', subsect, indent + 4)
app.builder.build(['only'])
app.build(filenames=[app.srcdir / 'only.rst'])
doctree = app.env.get_doctree('only')
app.env.apply_post_transforms(doctree, 'only')

View File

View File

@ -658,14 +658,14 @@ def extract_role_links(app, filename):
@pytest.mark.sphinx(testroot='domain-c', confoverrides={'nitpicky': True})
def test_domain_c_build(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
ws = filter_warnings(warning, "index")
assert len(ws) == 0
@pytest.mark.sphinx(testroot='domain-c', confoverrides={'nitpicky': True})
def test_domain_c_build_namespace(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
ws = filter_warnings(warning, "namespace")
assert len(ws) == 0
t = (app.outdir / "namespace.html").read_text(encoding='utf8')
@ -675,7 +675,7 @@ def test_domain_c_build_namespace(app, status, warning):
@pytest.mark.sphinx(testroot='domain-c', confoverrides={'nitpicky': True})
def test_domain_c_build_anon_dup_decl(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
ws = filter_warnings(warning, "anon-dup-decl")
assert len(ws) == 2
assert "WARNING: c:identifier reference target not found: @a" in ws[0]
@ -704,7 +704,7 @@ def test_domain_c_build_semicolon(app, warning):
@pytest.mark.sphinx(testroot='domain-c', confoverrides={'nitpicky': True})
def test_domain_c_build_function_param_target(app, warning):
# the anchor for function parameters should be the function
app.builder.build_all()
app.build(force_all=True)
ws = filter_warnings(warning, "function_param_target")
assert len(ws) == 0
entries = extract_role_links(app, "function_param_target.html")
@ -716,14 +716,14 @@ def test_domain_c_build_function_param_target(app, warning):
@pytest.mark.sphinx(testroot='domain-c', confoverrides={'nitpicky': True})
def test_domain_c_build_ns_lookup(app, warning):
app.builder.build_all()
app.build(force_all=True)
ws = filter_warnings(warning, "ns_lookup")
assert len(ws) == 0
@pytest.mark.sphinx(testroot='domain-c', confoverrides={'nitpicky': True})
def test_domain_c_build_field_role(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
ws = filter_warnings(warning, "field-role")
assert len(ws) == 0
@ -782,7 +782,7 @@ _var c:member 1 index.html#c.$ -
normalize_intersphinx_mapping(app, app.config)
load_mappings(app)
app.builder.build_all()
app.build(force_all=True)
ws = filter_warnings(warning, "index")
assert len(ws) == 0

View File

@ -1116,7 +1116,7 @@ def filter_warnings(warning, file):
@pytest.mark.sphinx(testroot='domain-cpp', confoverrides={'nitpicky': True})
def test_domain_cpp_build_multi_decl_lookup(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
ws = filter_warnings(warning, "lookup-key-overload")
assert len(ws) == 0
@ -1126,7 +1126,7 @@ def test_domain_cpp_build_multi_decl_lookup(app, status, warning):
@pytest.mark.sphinx(testroot='domain-cpp', confoverrides={'nitpicky': True})
def test_domain_cpp_build_warn_template_param_qualified_name(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
ws = filter_warnings(warning, "warn-template-param-qualified-name")
assert len(ws) == 2
assert "WARNING: cpp:type reference target not found: T::typeWarn" in ws[0]
@ -1135,14 +1135,14 @@ def test_domain_cpp_build_warn_template_param_qualified_name(app, status, warnin
@pytest.mark.sphinx(testroot='domain-cpp', confoverrides={'nitpicky': True})
def test_domain_cpp_build_backslash_ok_true(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
ws = filter_warnings(warning, "backslash")
assert len(ws) == 0
@pytest.mark.sphinx(testroot='domain-cpp', confoverrides={'nitpicky': True})
def test_domain_cpp_build_semicolon(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
ws = filter_warnings(warning, "semicolon")
assert len(ws) == 0
@ -1150,7 +1150,7 @@ def test_domain_cpp_build_semicolon(app, status, warning):
@pytest.mark.sphinx(testroot='domain-cpp',
confoverrides={'nitpicky': True, 'strip_signature_backslash': True})
def test_domain_cpp_build_backslash_ok_false(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
ws = filter_warnings(warning, "backslash")
assert len(ws) == 1
assert "WARNING: Parsing of expression failed. Using fallback parser." in ws[0]
@ -1158,7 +1158,7 @@ def test_domain_cpp_build_backslash_ok_false(app, status, warning):
@pytest.mark.sphinx(testroot='domain-cpp', confoverrides={'nitpicky': True})
def test_domain_cpp_build_anon_dup_decl(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
ws = filter_warnings(warning, "anon-dup-decl")
assert len(ws) == 2
assert "WARNING: cpp:identifier reference target not found: @a" in ws[0]
@ -1167,7 +1167,7 @@ def test_domain_cpp_build_anon_dup_decl(app, status, warning):
@pytest.mark.sphinx(testroot='domain-cpp')
def test_domain_cpp_build_misuse_of_roles(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
ws = filter_warnings(warning, "roles-targets-ok")
assert len(ws) == 0
@ -1215,7 +1215,7 @@ def test_domain_cpp_build_misuse_of_roles(app, status, warning):
@pytest.mark.sphinx(testroot='domain-cpp', confoverrides={'add_function_parentheses': True})
def test_domain_cpp_build_with_add_function_parentheses_is_True(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
def check(spec, text, file):
pattern = '<li><p>%s<a .*?><code .*?><span .*?>%s</span></code></a></p></li>' % spec
@ -1256,7 +1256,7 @@ def test_domain_cpp_build_with_add_function_parentheses_is_True(app, status, war
@pytest.mark.sphinx(testroot='domain-cpp', confoverrides={'add_function_parentheses': False})
def test_domain_cpp_build_with_add_function_parentheses_is_False(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
def check(spec, text, file):
pattern = '<li><p>%s<a .*?><code .*?><span .*?>%s</span></code></a></p></li>' % spec
@ -1297,7 +1297,7 @@ def test_domain_cpp_build_with_add_function_parentheses_is_False(app, status, wa
@pytest.mark.sphinx(testroot='domain-cpp')
def test_domain_cpp_build_xref_consistency(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
test = 'xref_consistency.html'
output = (app.outdir / test).read_text(encoding='utf8')
@ -1361,7 +1361,7 @@ not found in `{test}`
@pytest.mark.sphinx(testroot='domain-cpp', confoverrides={'nitpicky': True})
def test_domain_cpp_build_field_role(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
ws = filter_warnings(warning, "field-role")
assert len(ws) == 0
@ -1424,7 +1424,7 @@ _var cpp:member 1 index.html#_CPPv44$ -
normalize_intersphinx_mapping(app, app.config)
load_mappings(app)
app.builder.build_all()
app.build(force_all=True)
ws = filter_warnings(warning, "index")
assert len(ws) == 0

View File

@ -28,7 +28,7 @@ from sphinx.writers.text import STDINDENT
@pytest.mark.sphinx('dummy', testroot='domain-js')
def test_domain_js_xrefs(app, status, warning):
"""Domain objects have correct prefixes when looking up xrefs"""
app.builder.build_all()
app.build(force_all=True)
def assert_refnode(node, mod_name, prefix, target, reftype=None,
domain='js'):
@ -83,7 +83,7 @@ def test_domain_js_xrefs(app, status, warning):
@pytest.mark.sphinx('dummy', testroot='domain-js')
def test_domain_js_objects(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
modules = app.env.domains['js'].data['modules']
objects = app.env.domains['js'].data['objects']
@ -118,7 +118,7 @@ def test_domain_js_find_obj(app, status, warning):
return app.env.domains['js'].find_obj(
app.env, mod_name, prefix, obj_name, obj_type, searchmode)
app.builder.build_all()
app.build(force_all=True)
assert (find_obj(None, None, 'NONEXISTANT', 'class') == (None, None))
assert (find_obj(None, None, 'NestedParentA', 'class') ==

View File

@ -78,7 +78,7 @@ def test_function_signatures():
@pytest.mark.sphinx('dummy', testroot='domain-py')
def test_domain_py_xrefs(app, status, warning):
"""Domain objects have correct prefixes when looking up xrefs"""
app.builder.build_all()
app.build(force_all=True)
def assert_refnode(node, module_name, class_name, target, reftype=None,
domain='py'):
@ -153,7 +153,7 @@ def test_domain_py_xrefs(app, status, warning):
@pytest.mark.sphinx('html', testroot='domain-py')
def test_domain_py_xrefs_abbreviations(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'abbr.html').read_text(encoding='utf8')
assert re.search(r'normal: <a .* href="module.html#module_a.submodule.ModTopLevel.'
@ -176,7 +176,7 @@ def test_domain_py_xrefs_abbreviations(app, status, warning):
@pytest.mark.sphinx('dummy', testroot='domain-py')
def test_domain_py_objects(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
modules = app.env.domains['py'].data['modules']
objects = app.env.domains['py'].data['objects']
@ -208,7 +208,7 @@ def test_domain_py_objects(app, status, warning):
@pytest.mark.sphinx('html', testroot='domain-py')
def test_resolve_xref_for_properties(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'module.html').read_text(encoding='utf8')
assert ('Link to <a class="reference internal" href="#module_a.submodule.ModTopLevel.prop"'
@ -232,7 +232,7 @@ def test_domain_py_find_obj(app, status, warning):
return app.env.domains['py'].find_obj(
app.env, modname, prefix, obj_name, obj_type, searchmode)
app.builder.build_all()
app.build(force_all=True)
assert (find_obj(None, None, 'NONEXISTANT', 'class') == [])
assert (find_obj(None, None, 'NestedParentA', 'class') ==
@ -256,7 +256,7 @@ def test_domain_py_find_obj(app, status, warning):
@pytest.mark.sphinx('html', testroot='domain-py', freshenv=True)
def test_domain_py_canonical(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'canonical.html').read_text(encoding='utf8')
assert ('<a class="reference internal" href="#canonical.Foo" title="canonical.Foo">'

View File

@ -368,7 +368,7 @@ def test_multiple_cmdoptions(app):
@pytest.mark.sphinx(testroot='productionlist')
def test_productionlist(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
warnings = warning.getvalue().split("\n")
assert len(warnings) == 2

View File

View File

View File

@ -2279,7 +2279,7 @@ def test_pyclass_for_ClassLevelDocumenter(app):
@pytest.mark.sphinx('dummy', testroot='ext-autodoc')
def test_autodoc(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
content = app.env.get_doctree('index')
assert isinstance(content[3], addnodes.desc)

View File

@ -6,7 +6,7 @@ source file translated by test_build.
import pytest
from .test_ext_autodoc import do_autodoc
from tests.test_extensions.test_ext_autodoc import do_autodoc
@pytest.mark.sphinx('html', testroot='ext-autodoc')

View File

@ -11,7 +11,7 @@ from typing import Union
import pytest
from .test_ext_autodoc import do_autodoc
from tests.test_extensions.test_ext_autodoc import do_autodoc
@pytest.mark.sphinx('html', testroot='ext-autodoc')

View File

@ -6,7 +6,7 @@ source file translated by test_build.
import pytest
from .test_ext_autodoc import do_autodoc
from tests.test_extensions.test_ext_autodoc import do_autodoc
@pytest.mark.sphinx('html', testroot='ext-autodoc')

View File

@ -6,7 +6,7 @@ source file translated by test_build.
import pytest
from .test_ext_autodoc import do_autodoc
from tests.test_extensions.test_ext_autodoc import do_autodoc
@pytest.mark.sphinx('html', testroot='ext-autodoc')

View File

@ -8,7 +8,7 @@ import sys
import pytest
from .test_ext_autodoc import do_autodoc
from tests.test_extensions.test_ext_autodoc import do_autodoc
@pytest.mark.sphinx('html', testroot='ext-autodoc')

View File

@ -6,7 +6,7 @@ source file translated by test_build.
import pytest
from .test_ext_autodoc import do_autodoc
from tests.test_extensions.test_ext_autodoc import do_autodoc
@pytest.mark.sphinx('html', testroot='ext-autodoc')

View File

@ -8,7 +8,7 @@ import pytest
from sphinx.testing import restructuredtext
from .test_ext_autodoc import do_autodoc
from tests.test_extensions.test_ext_autodoc import do_autodoc
IS_PYPY = platform.python_implementation() == 'PyPy'

View File

@ -4,7 +4,7 @@ import pytest
from sphinx.ext.autodoc import between, cut_lines
from .test_ext_autodoc import do_autodoc
from tests.test_extensions.test_ext_autodoc import do_autodoc
@pytest.mark.sphinx('html', testroot='ext-autodoc')

View File

@ -2,7 +2,7 @@
import pytest
from .test_ext_autodoc import do_autodoc
from tests.test_extensions.test_ext_autodoc import do_autodoc
@pytest.mark.sphinx('html', testroot='ext-autodoc',

View File

@ -3,7 +3,7 @@
import pytest
from .test_ext_autodoc import do_autodoc
from tests.test_extensions.test_ext_autodoc import do_autodoc
@pytest.mark.sphinx('html', testroot='ext-autodoc')

View File

@ -7,7 +7,7 @@ import pytest
@pytest.mark.sphinx('html', testroot='ext-autosectionlabel')
def test_autosectionlabel_html(app, status, warning, skipped_labels=False):
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'index.html').read_text(encoding='utf8')
html = ('<li><p><a class="reference internal" href="#introduce-of-sphinx">'
@ -51,7 +51,7 @@ def test_autosectionlabel_prefix_document_html(app, status, warning):
@pytest.mark.sphinx('html', testroot='ext-autosectionlabel',
confoverrides={'autosectionlabel_maxdepth': 3})
def test_autosectionlabel_maxdepth(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'index.html').read_text(encoding='utf8')

View File

@ -167,7 +167,7 @@ def test_get_items_summary(make_app, app_params):
sphinx.ext.autosummary.Autosummary.get_items = new_get_items
try:
app.builder.build_all()
app.build(force_all=True)
finally:
sphinx.ext.autosummary.Autosummary.get_items = orig_get_items
@ -207,7 +207,7 @@ def str_content(elem):
@pytest.mark.sphinx('xml', **default_kw)
def test_escaping(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
outdir = Path(app.builder.outdir)
@ -358,7 +358,7 @@ def test_autosummary_generate_content_for_module_imported_members_inherited_modu
@pytest.mark.sphinx('dummy', testroot='ext-autosummary')
def test_autosummary_generate(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
doctree = app.env.get_doctree('index')
assert_node(doctree, (nodes.paragraph,
@ -544,7 +544,7 @@ def test_autosummary_filename_map(app, status, warning):
@pytest.mark.sphinx('latex', **default_kw)
def test_autosummary_latex_table_colspec(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
print(status.getvalue())
print(warning.getvalue())

View File

@ -7,7 +7,7 @@ import pytest
@pytest.mark.sphinx('coverage')
def test_build(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
py_undoc = (app.outdir / 'python.txt').read_text(encoding='utf8')
assert py_undoc.startswith('Undocumented Python objects\n'
@ -45,7 +45,7 @@ def test_build(app, status, warning):
@pytest.mark.sphinx('coverage', testroot='ext-coverage')
def test_coverage_ignore_pyobjects(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
actual = (app.outdir / 'python.txt').read_text(encoding='utf8')
expected = '''\
Undocumented Python objects
@ -78,7 +78,7 @@ Classes:
@pytest.mark.sphinx('coverage', confoverrides={'coverage_show_missing_items': True})
def test_show_missing_items(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
assert "undocumented" in status.getvalue()
@ -92,7 +92,7 @@ def test_show_missing_items(app, status, warning):
@pytest.mark.sphinx('coverage', confoverrides={'coverage_show_missing_items': True})
def test_show_missing_items_quiet(app, status, warning):
app.quiet = True
app.builder.build_all()
app.build(force_all=True)
assert "undocumented python function: autodoc_target :: raises" in warning.getvalue()
assert "undocumented python class: autodoc_target :: Base" in warning.getvalue()

View File

@ -16,9 +16,8 @@ cleanup_called = 0
def test_build(app, status, warning):
global cleanup_called
cleanup_called = 0
app.builder.build_all()
if app.statuscode != 0:
raise AssertionError('failures in doctests:' + status.getvalue())
app.build(force_all=True)
assert app.statuscode == 0, f'failures in doctests:\n{status.getvalue()}'
# in doctest.txt, there are two named groups and the default group,
# so the cleanup function must be called three times
assert cleanup_called == 3, 'testcleanup did not get executed enough times'
@ -80,13 +79,13 @@ def test_skipif(app, status, warning):
The tests are separated into a different test root directory since the
``app`` object only evaluates options once in its lifetime. If these tests
were combined with the other doctest tests, the ``:skipif:`` evaluations
would be recorded only on the first ``app.builder.build_all()`` run, i.e.
would be recorded only on the first ``app.build(force_all=True)`` run, i.e.
in ``test_build`` above, and the assertion below would fail.
"""
global recorded_calls
recorded_calls = Counter()
app.builder.build_all()
app.build(force_all=True)
if app.statuscode != 0:
raise AssertionError('failures in doctests:' + status.getvalue())
# The `:skipif:` expressions are always run.
@ -124,7 +123,7 @@ def test_reporting_with_autodoc(app, status, warning, capfd):
# Patch builder to get a copy of the output
written = []
app.builder._warn_out = written.append
app.builder.build_all()
app.build(force_all=True)
failures = [line.replace(os.sep, '/')
for line in '\n'.join(written).splitlines()

View File

@ -5,7 +5,7 @@ import pytest
@pytest.mark.sphinx('html', testroot='ext-githubpages')
def test_githubpages(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
assert (app.outdir / '.nojekyll').exists()
assert not (app.outdir / 'CNAME').exists()
@ -13,7 +13,7 @@ def test_githubpages(app, status, warning):
@pytest.mark.sphinx('html', testroot='ext-githubpages',
confoverrides={'html_baseurl': 'https://sphinx-doc.github.io'})
def test_no_cname_for_github_io_domain(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
assert (app.outdir / '.nojekyll').exists()
assert not (app.outdir / 'CNAME').exists()
@ -21,6 +21,6 @@ def test_no_cname_for_github_io_domain(app, status, warning):
@pytest.mark.sphinx('html', testroot='ext-githubpages',
confoverrides={'html_baseurl': 'https://sphinx-doc.org'})
def test_cname_for_custom_domain(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
assert (app.outdir / '.nojekyll').exists()
assert (app.outdir / 'CNAME').read_text(encoding='utf8') == 'sphinx-doc.org'

View File

@ -11,7 +11,7 @@ from sphinx.ext.graphviz import ClickableMapDefinition
@pytest.mark.sphinx('html', testroot='ext-graphviz')
@pytest.mark.usefixtures('if_graphviz_found')
def test_graphviz_png_html(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'index.html').read_text(encoding='utf8')
html = (r'<figure class="align-default" .*?>\s*'
@ -44,7 +44,7 @@ def test_graphviz_png_html(app, status, warning):
confoverrides={'graphviz_output_format': 'svg'})
@pytest.mark.usefixtures('if_graphviz_found')
def test_graphviz_svg_html(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'index.html').read_text(encoding='utf8')
@ -103,7 +103,7 @@ def test_graphviz_svg_html(app, status, warning):
@pytest.mark.sphinx('latex', testroot='ext-graphviz')
@pytest.mark.usefixtures('if_graphviz_found')
def test_graphviz_latex(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'python.tex').read_text(encoding='utf8')
macro = ('\\\\begin{figure}\\[htbp\\]\n\\\\centering\n\\\\capstart\n\n'
@ -129,7 +129,7 @@ def test_graphviz_latex(app, status, warning):
@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()
app.build(force_all=True)
content = (app.outdir / 'index.html').read_text(encoding='utf8')
html = '<img src=".*?" alt="digraph {\n BAR -&gt; BAZ\n}" class="graphviz" />'

View File

@ -9,7 +9,7 @@ from sphinx.testing import restructuredtext
@pytest.mark.sphinx('text', testroot='ext-ifconfig')
def test_ifconfig(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
result = (app.outdir / 'index.txt').read_text(encoding='utf8')
assert 'spam' in result
assert 'ham' not in result

View File

@ -22,7 +22,7 @@ def _if_converter_found(app):
@pytest.mark.usefixtures('_if_converter_found')
@pytest.mark.sphinx('latex', testroot='ext-imgconverter')
def test_ext_imgconverter(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'python.tex').read_text(encoding='utf8')

View File

@ -5,7 +5,7 @@ import pytest
@pytest.mark.sphinx('latex', testroot='ext-imgmockconverter')
def test_ext_imgmockconverter(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'python.tex').read_text(encoding='utf8')

View File

@ -33,7 +33,7 @@ def test_inheritance_diagram(app, status, warning):
InheritanceDiagram.run = new_run
try:
app.builder.build_all()
app.build(force_all=True)
finally:
InheritanceDiagram.run = orig_run
@ -160,7 +160,7 @@ def test_inheritance_diagram_png_html(tmp_path, app):
normalize_intersphinx_mapping(app, app.config)
load_mappings(app)
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'index.html').read_text(encoding='utf8')
base_maps = re.findall('<map .+\n.+\n</map>', content)
@ -207,7 +207,7 @@ def test_inheritance_diagram_svg_html(tmp_path, app):
normalize_intersphinx_mapping(app, app.config)
load_mappings(app)
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'index.html').read_text(encoding='utf8')
base_svgs = re.findall('<object data="(_images/inheritance-\\w+.svg?)"', content)
@ -249,7 +249,7 @@ def test_inheritance_diagram_svg_html(tmp_path, app):
@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()
app.build(force_all=True)
content = (app.outdir / 'python.tex').read_text(encoding='utf8')
@ -264,7 +264,7 @@ def test_inheritance_diagram_latex(app, status, warning):
@pytest.mark.usefixtures('if_graphviz_found')
def test_inheritance_diagram_latex_alias(app, status, warning):
app.config.inheritance_alias = {'test.Foo': 'alias.Foo'}
app.builder.build_all()
app.build(force_all=True)
doc = app.env.get_and_resolve_doctree('index', app)
aliased_graph = doc.children[0].children[3]['graph'].class_info

View File

@ -19,8 +19,8 @@ from sphinx.ext.intersphinx import (
)
from sphinx.ext.intersphinx import setup as intersphinx_setup
from .test_util_inventory import inventory_v2, inventory_v2_not_having_version
from .utils import http_server
from tests.test_util.test_util_inventory import inventory_v2, inventory_v2_not_having_version
from tests.utils import http_server
def fake_node(domain, type, target, content, **attrs):

View File

@ -27,7 +27,7 @@ def has_binary(binary):
@pytest.mark.sphinx('html', testroot='ext-math-simple',
confoverrides={'extensions': ['sphinx.ext.imgmath']})
def test_imgmath_png(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
if "LaTeX command 'latex' cannot be run" in warning.getvalue():
msg = 'LaTeX command "latex" is not available'
raise pytest.skip.Exception(msg)
@ -48,7 +48,7 @@ def test_imgmath_png(app, status, warning):
confoverrides={'extensions': ['sphinx.ext.imgmath'],
'imgmath_image_format': 'svg'})
def test_imgmath_svg(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
if "LaTeX command 'latex' cannot be run" in warning.getvalue():
msg = 'LaTeX command "latex" is not available'
raise pytest.skip.Exception(msg)
@ -70,7 +70,7 @@ def test_imgmath_svg(app, status, warning):
'imgmath_image_format': 'svg',
'imgmath_embed': True})
def test_imgmath_svg_embed(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
if "LaTeX command 'latex' cannot be run" in warning.getvalue():
msg = 'LaTeX command "latex" is not available'
raise pytest.skip.Exception(msg)
@ -88,7 +88,7 @@ def test_imgmath_svg_embed(app, status, warning):
confoverrides={'extensions': ['sphinx.ext.mathjax'],
'mathjax_options': {'integrity': 'sha384-0123456789'}})
def test_mathjax_options(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'index.html').read_text(encoding='utf8')
shutil.rmtree(app.outdir)
@ -100,7 +100,7 @@ def test_mathjax_options(app, status, warning):
@pytest.mark.sphinx('html', testroot='ext-math',
confoverrides={'extensions': ['sphinx.ext.mathjax']})
def test_mathjax_align(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'index.html').read_text(encoding='utf8')
shutil.rmtree(app.outdir)
@ -155,7 +155,7 @@ def test_math_number_all_latex(app, status, warning):
confoverrides={'extensions': ['sphinx.ext.mathjax'],
'math_eqref_format': 'Eq.{number}'})
def test_math_eqref_format_html(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'math.html').read_text(encoding='utf8')
html = ('<p>Referencing equation <a class="reference internal" '
@ -168,7 +168,7 @@ def test_math_eqref_format_html(app, status, warning):
confoverrides={'extensions': ['sphinx.ext.mathjax'],
'math_eqref_format': 'Eq.{number}'})
def test_math_eqref_format_latex(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'python.tex').read_text(encoding='utf8')
macro = (r'Referencing equation Eq.\\ref{equation:math:foo} and '
@ -181,7 +181,7 @@ def test_math_eqref_format_latex(app, status, warning):
'numfig': True,
'math_numfig': True})
def test_mathjax_numfig_html(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'math.html').read_text(encoding='utf8')
html = ('<div class="math notranslate nohighlight" id="equation-math-0">\n'
@ -199,7 +199,7 @@ def test_mathjax_numfig_html(app, status, warning):
'numfig_secnum_depth': 0,
'math_numfig': True})
def test_imgmath_numfig_html(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'page.html').read_text(encoding='utf8')
html = '<span class="eqno">(3)<a class="headerlink" href="#equation-bar"'
@ -213,7 +213,7 @@ def test_imgmath_numfig_html(app, status, warning):
@pytest.mark.sphinx('dummy', testroot='ext-math-compat')
def test_math_compat(app, status, warning):
with warnings.catch_warnings(record=True):
app.builder.build_all()
app.build(force_all=True)
doctree = app.env.get_and_resolve_doctree('index', app.builder)
assert_node(doctree,
@ -239,7 +239,7 @@ def test_math_compat(app, status, warning):
confoverrides={'extensions': ['sphinx.ext.mathjax'],
'mathjax3_config': {'extensions': ['tex2jax.js']}})
def test_mathjax3_config(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'index.html').read_text(encoding='utf8')
assert MATHJAX_URL in content
@ -251,7 +251,7 @@ def test_mathjax3_config(app, status, warning):
confoverrides={'extensions': ['sphinx.ext.mathjax'],
'mathjax2_config': {'extensions': ['tex2jax.js']}})
def test_mathjax2_config(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'index.html').read_text(encoding='utf8')
assert ('<script async="async" src="%s">' % MATHJAX_URL in content)
@ -265,7 +265,7 @@ def test_mathjax2_config(app, status, warning):
'mathjax_options': {'async': 'async'},
'mathjax3_config': {'extensions': ['tex2jax.js']}})
def test_mathjax_options_async_for_mathjax3(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'index.html').read_text(encoding='utf8')
assert MATHJAX_URL in content
@ -277,7 +277,7 @@ def test_mathjax_options_async_for_mathjax3(app, status, warning):
'mathjax_options': {'defer': 'defer'},
'mathjax2_config': {'extensions': ['tex2jax.js']}})
def test_mathjax_options_defer_for_mathjax2(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'index.html').read_text(encoding='utf8')
assert ('<script defer="defer" src="%s">' % MATHJAX_URL in content)
@ -291,7 +291,7 @@ def test_mathjax_options_defer_for_mathjax2(app, status, warning):
},
)
def test_mathjax_path(app):
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'index.html').read_text(encoding='utf8')
assert '<script async="async" src="_static/MathJax.js"></script>' in content
@ -305,7 +305,7 @@ def test_mathjax_path(app):
},
)
def test_mathjax_path_config(app):
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'index.html').read_text(encoding='utf8')
assert '<script async="async" src="_static/MathJax.js?config=scipy-mathjax"></script>' in content
@ -314,7 +314,7 @@ def test_mathjax_path_config(app):
@pytest.mark.sphinx('html', testroot='ext-math',
confoverrides={'extensions': ['sphinx.ext.mathjax']})
def test_mathjax_is_installed_only_if_document_having_math(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'index.html').read_text(encoding='utf8')
assert MATHJAX_URL in content
@ -326,7 +326,7 @@ def test_mathjax_is_installed_only_if_document_having_math(app, status, warning)
@pytest.mark.sphinx('html', testroot='basic',
confoverrides={'extensions': ['sphinx.ext.mathjax']})
def test_mathjax_is_not_installed_if_no_equations(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'index.html').read_text(encoding='utf8')
assert 'MathJax.js' not in content
@ -336,7 +336,7 @@ def test_mathjax_is_not_installed_if_no_equations(app, status, warning):
confoverrides={'extensions': ['sphinx.ext.mathjax']})
def test_mathjax_is_installed_if_no_equations_when_forced(app, status, warning):
app.set_html_assets_policy('always')
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'index.html').read_text(encoding='utf8')
assert MATHJAX_URL in content
@ -348,7 +348,7 @@ def test_mathjax_is_installed_if_no_equations_when_forced(app, status, warning):
@pytest.mark.sphinx('html', testroot='ext-math-include',
confoverrides={'extensions': ['sphinx.ext.mathjax']})
def test_mathjax_is_installed_if_included_file_has_equations(app):
app.builder.build_all()
app.build(force_all=True)
# no real equations at the rst level, but includes "included"
content = (app.outdir / 'index.html').read_text(encoding='utf8')
@ -365,7 +365,7 @@ def test_mathjax_is_installed_if_included_file_has_equations(app):
@pytest.mark.sphinx('singlehtml', testroot='ext-math',
confoverrides={'extensions': ['sphinx.ext.mathjax']})
def test_mathjax_is_installed_only_if_document_having_math_singlehtml(app):
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'index.html').read_text(encoding='utf8')
assert MATHJAX_URL in content
@ -374,7 +374,7 @@ def test_mathjax_is_installed_only_if_document_having_math_singlehtml(app):
@pytest.mark.sphinx('singlehtml', testroot='basic',
confoverrides={'extensions': ['sphinx.ext.mathjax']})
def test_mathjax_is_not_installed_if_no_equations_singlehtml(app):
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'index.html').read_text(encoding='utf8')
assert 'MathJax.js' not in content
@ -383,7 +383,7 @@ def test_mathjax_is_not_installed_if_no_equations_singlehtml(app):
@pytest.mark.sphinx('singlehtml', testroot='ext-math-include',
confoverrides={'extensions': ['sphinx.ext.mathjax']})
def test_mathjax_is_installed_if_included_file_has_equations_singlehtml(app):
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'index.html').read_text(encoding='utf8')
assert MATHJAX_URL in content

View File

@ -18,8 +18,8 @@ from sphinx.ext.napoleon.docstring import (
_tokenize_type_spec,
)
from .ext_napoleon_pep526_data_google import PEP526GoogleClass
from .ext_napoleon_pep526_data_numpy import PEP526NumpyClass
from tests.test_extensions.ext_napoleon_pep526_data_google import PEP526GoogleClass
from tests.test_extensions.ext_napoleon_pep526_data_numpy import PEP526NumpyClass
class NamedtupleSubclass(namedtuple('NamedtupleSubclass', ('attr1', 'attr2'))):

View File

@ -14,7 +14,7 @@ def test_todo(app, status, warning):
todos.append(node)
app.connect('todo-defined', on_todo_defined)
app.builder.build_all()
app.build(force_all=True)
# check todolist
content = (app.outdir / 'index.html').read_text(encoding='utf8')
@ -52,7 +52,7 @@ def test_todo_not_included(app, status, warning):
todos.append(node)
app.connect('todo-defined', on_todo_defined)
app.builder.build_all()
app.build(force_all=True)
# check todolist
content = (app.outdir / 'index.html').read_text(encoding='utf8')
@ -87,7 +87,7 @@ def test_todo_valid_link(app, status, warning):
omitted (GitHub issue #1020).
"""
# Ensure the LaTeX output is built.
app.builder.build_all()
app.build(force_all=True)
content = (app.outdir / 'python.tex').read_text(encoding='utf8')

View File

@ -44,7 +44,7 @@ def check_viewcode_output(app, warning):
confoverrides={"viewcode_line_numbers": True})
def test_viewcode_linenos(app, warning):
shutil.rmtree(app.outdir / '_modules', ignore_errors=True)
app.builder.build_all()
app.build(force_all=True)
result = check_viewcode_output(app, warning)
assert '<span class="linenos"> 1</span>' in result
@ -54,7 +54,7 @@ def test_viewcode_linenos(app, warning):
confoverrides={"viewcode_line_numbers": False})
def test_viewcode(app, warning):
shutil.rmtree(app.outdir / '_modules', ignore_errors=True)
app.builder.build_all()
app.build(force_all=True)
result = check_viewcode_output(app, warning)
assert 'class="linenos">' not in result
@ -63,7 +63,7 @@ def test_viewcode(app, warning):
@pytest.mark.sphinx('epub', testroot='ext-viewcode')
def test_viewcode_epub_default(app, status, warning):
shutil.rmtree(app.outdir)
app.builder.build_all()
app.build(force_all=True)
assert not (app.outdir / '_modules/spam/mod1.xhtml').exists()
@ -74,7 +74,7 @@ def test_viewcode_epub_default(app, status, warning):
@pytest.mark.sphinx('epub', testroot='ext-viewcode',
confoverrides={'viewcode_enable_epub': True})
def test_viewcode_epub_enabled(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
assert (app.outdir / '_modules/spam/mod1.xhtml').exists()
@ -84,7 +84,7 @@ def test_viewcode_epub_enabled(app, status, warning):
@pytest.mark.sphinx(testroot='ext-viewcode', tags=['test_linkcode'])
def test_linkcode(app, status, warning):
app.builder.build(['objects'])
app.build(filenames=[app.srcdir / 'objects.rst'])
stuff = (app.outdir / 'objects.html').read_text(encoding='utf8')
@ -117,7 +117,7 @@ def test_local_source_files(app, status, warning):
return (source, tags)
app.connect('viewcode-find-source', find_source)
app.builder.build_all()
app.build(force_all=True)
warnings = re.sub(r'\\+', '/', warning.getvalue())
assert re.findall(

View File

View File

@ -612,7 +612,7 @@ def test_gettext_buildr_ignores_only_directive(app):
@sphinx_intl
def test_node_translated_attribute(app):
app.builder.build_specific([app.srcdir / 'translation_progress.txt'])
app.build(filenames=[app.srcdir / 'translation_progress.txt'])
doctree = app.env.get_doctree('translation_progress')
@ -625,7 +625,7 @@ def test_node_translated_attribute(app):
@sphinx_intl
def test_translation_progress_substitution(app):
app.builder.build_specific([app.srcdir / 'translation_progress.txt'])
app.build(filenames=[app.srcdir / 'translation_progress.txt'])
doctree = app.env.get_doctree('translation_progress')
@ -638,7 +638,7 @@ def test_translation_progress_substitution(app):
'translation_progress_classes': True,
})
def test_translation_progress_classes_true(app):
app.builder.build_specific([app.srcdir / 'translation_progress.txt'])
app.build(filenames=[app.srcdir / 'translation_progress.txt'])
doctree = app.env.get_doctree('translation_progress')
@ -868,7 +868,7 @@ def test_html_template(app):
def test_html_rebuild_mo(app):
app.build()
# --- rebuild by .mo mtime
app.builder.build_update()
app.build()
app.env.find_files(app.config, app.builder)
_, updated, _ = app.env.get_outdated_files(config_changed=False)
assert len(updated) == 0
@ -1306,7 +1306,7 @@ def test_additional_targets_should_be_translated(app):
},
)
def test_additional_targets_should_be_translated_substitution_definitions(app):
app.builder.build_all()
app.build(force_all=True)
# [prolog_epilog_substitution.txt]
@ -1325,7 +1325,7 @@ def test_additional_targets_should_be_translated_substitution_definitions(app):
@pytest.mark.sphinx('text')
@pytest.mark.test_params(shared_result='test_intl_basic')
def test_text_references(app, warning):
app.builder.build_specific([app.srcdir / 'refs.txt'])
app.build(filenames=[app.srcdir / 'refs.txt'])
warnings = warning.getvalue().replace(os.sep, '/')
warning_expr = 'refs.txt:\\d+: ERROR: Unknown target name:'

View File

View File

@ -520,7 +520,7 @@ def test_XRefRole(inliner):
@pytest.mark.sphinx('dummy', testroot='prolog')
def test_rst_prolog(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
rst = app.env.get_doctree('restructuredtext')
md = app.env.get_doctree('markdown')
@ -544,7 +544,7 @@ def test_rst_prolog(app, status, warning):
@pytest.mark.sphinx('dummy', testroot='keep_warnings')
def test_keep_warnings_is_True(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
doctree = app.env.get_doctree('index')
assert_node(doctree[0], nodes.section)
assert len(doctree[0]) == 2
@ -554,7 +554,7 @@ def test_keep_warnings_is_True(app, status, warning):
@pytest.mark.sphinx('dummy', testroot='keep_warnings',
confoverrides={'keep_warnings': False})
def test_keep_warnings_is_False(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
doctree = app.env.get_doctree('index')
assert_node(doctree[0], nodes.section)
assert len(doctree[0]) == 1
@ -562,7 +562,7 @@ def test_keep_warnings_is_False(app, status, warning):
@pytest.mark.sphinx('dummy', testroot='refonly_bullet_list')
def test_compact_refonly_bullet_list(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
doctree = app.env.get_doctree('index')
assert_node(doctree[0], nodes.section)
assert len(doctree[0]) == 5
@ -580,7 +580,7 @@ def test_compact_refonly_bullet_list(app, status, warning):
@pytest.mark.sphinx('dummy', testroot='default_role')
def test_default_role1(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
# default-role: pep
doctree = app.env.get_doctree('index')
@ -601,7 +601,7 @@ def test_default_role1(app, status, warning):
@pytest.mark.sphinx('dummy', testroot='default_role',
confoverrides={'default_role': 'guilabel'})
def test_default_role2(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
# default-role directive is stronger than configratuion
doctree = app.env.get_doctree('index')

View File

View File

@ -211,7 +211,7 @@ def test_quickstart_and_build(tmp_path):
'html', # buildername
status=StringIO(),
warning=warnfile)
app.builder.build_all()
app.build(force_all=True)
warnings = warnfile.getvalue()
assert not warnings

View File

@ -72,7 +72,7 @@ test that non-comments are indexed: fermion
@pytest.mark.sphinx(testroot='ext-viewcode')
def test_objects_are_escaped(app):
app.builder.build_all()
app.build(force_all=True)
index = load_searchindex(app.outdir / 'searchindex.js')
for item in index.get('objects').get(''):
if item[-1] == 'n::Array&lt;T, d&gt;': # n::Array<T,d> is escaped
@ -83,7 +83,7 @@ def test_objects_are_escaped(app):
@pytest.mark.sphinx(testroot='search')
def test_meta_keys_are_handled_for_language_en(app):
app.builder.build_all()
app.build(force_all=True)
searchindex = load_searchindex(app.outdir / 'searchindex.js')
assert not is_registered_term(searchindex, 'thisnoteith')
assert is_registered_term(searchindex, 'thisonetoo')
@ -96,7 +96,7 @@ def test_meta_keys_are_handled_for_language_en(app):
@pytest.mark.sphinx(testroot='search', confoverrides={'html_search_language': 'de'}, freshenv=True)
def test_meta_keys_are_handled_for_language_de(app):
app.builder.build_all()
app.build(force_all=True)
searchindex = load_searchindex(app.outdir / 'searchindex.js')
assert not is_registered_term(searchindex, 'thisnoteith')
assert is_registered_term(searchindex, 'thisonetoo')
@ -109,14 +109,14 @@ def test_meta_keys_are_handled_for_language_de(app):
@pytest.mark.sphinx(testroot='search')
def test_stemmer_does_not_remove_short_words(app):
app.builder.build_all()
app.build(force_all=True)
searchindex = (app.outdir / 'searchindex.js').read_text(encoding='utf8')
assert 'bat' in searchindex
@pytest.mark.sphinx(testroot='search')
def test_stemmer(app):
app.builder.build_all()
app.build(force_all=True)
searchindex = load_searchindex(app.outdir / 'searchindex.js')
print(searchindex)
assert is_registered_term(searchindex, 'findthisstemmedkei')
@ -125,7 +125,7 @@ def test_stemmer(app):
@pytest.mark.sphinx(testroot='search')
def test_term_in_heading_and_section(app):
app.builder.build_all()
app.build(force_all=True)
searchindex = (app.outdir / 'searchindex.js').read_text(encoding='utf8')
# if search term is in the title of one doc and in the text of another
# both documents should be a hit in the search index as a title,
@ -136,7 +136,7 @@ def test_term_in_heading_and_section(app):
@pytest.mark.sphinx(testroot='search')
def test_term_in_raw_directive(app):
app.builder.build_all()
app.build(force_all=True)
searchindex = load_searchindex(app.outdir / 'searchindex.js')
assert not is_registered_term(searchindex, 'raw')
assert is_registered_term(searchindex, 'rawword')
@ -279,7 +279,7 @@ def test_IndexBuilder_lookup():
srcdir='search_zh',
)
def test_search_index_gen_zh(app):
app.builder.build_all()
app.build(force_all=True)
index = load_searchindex(app.outdir / 'searchindex.js')
assert 'chinesetest ' not in index['terms']
assert 'chinesetest' in index['terms']
@ -336,7 +336,7 @@ def test_search_index_is_deterministic(app):
for i, child in enumerate(item):
assert_is_sorted(child, f'{path}[{i}]')
app.builder.build_all()
app.build(force_all=True)
index = load_searchindex(app.outdir / 'searchindex.js')
# Pretty print the index. Only shown by pytest on failure.
print(f'searchindex.js contents:\n\n{json.dumps(index, indent=2)}')

View File

View File

@ -10,7 +10,7 @@ def test_layout_overloading(make_app, app_params):
args, kwargs = app_params
app = make_app(*args, **kwargs)
setup_documenters(app)
app.builder.build_update()
app.build()
result = (app.outdir / 'index.html').read_text(encoding='utf8')
assert '<!-- layout overloading -->' in result
@ -21,7 +21,7 @@ def test_autosummary_class_template_overloading(make_app, app_params):
args, kwargs = app_params
app = make_app(*args, **kwargs)
setup_documenters(app)
app.builder.build_update()
app.build()
result = (app.outdir / 'generated' / 'sphinx.application.TemplateBridge.html').read_text(encoding='utf8')
assert 'autosummary/class.rst method block overloading' in result
@ -34,7 +34,7 @@ def test_autosummary_context(make_app, app_params):
args, kwargs = app_params
app = make_app(*args, **kwargs)
setup_documenters(app)
app.builder.build_update()
app.build()
result = (app.outdir / 'generated' / 'sphinx.application.TemplateBridge.html').read_text(encoding='utf8')
assert 'autosummary/class.rst method block overloading' in result

View File

@ -6,7 +6,7 @@ import pytest
@pytest.mark.sphinx(testroot='toctree-glob')
def test_relations(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
assert app.builder.relations['index'] == [None, None, 'foo']
assert app.builder.relations['foo'] == ['index', 'index', 'bar/index']
assert app.builder.relations['bar/index'] == ['index', 'foo', 'bar/bar_1']
@ -23,7 +23,7 @@ def test_relations(app, status, warning):
@pytest.mark.sphinx('singlehtml', testroot='toctree-empty')
def test_singlehtml_toctree(app, status, warning):
app.builder.build_all()
app.build(force_all=True)
try:
app.builder._get_local_toctree('index')
except AttributeError:
@ -36,4 +36,4 @@ def test_numbered_toctree(app, status, warning):
index = (app.srcdir / 'index.rst').read_text(encoding='utf8')
index = re.sub(':numbered:.*', ':numbered: 1', index)
(app.srcdir / 'index.rst').write_text(index, encoding='utf8')
app.builder.build_all()
app.build(force_all=True)

View File

Some files were not shown because too many files have changed in this diff Show More