mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Use `app.status
and
app.warning
` in tests (#12663)
This commit is contained in:
parent
772cdfa19d
commit
1f2891530d
@ -48,7 +48,7 @@ def test_instantiation(
|
||||
assert isinstance(app_, sphinx.application.Sphinx)
|
||||
|
||||
|
||||
def test_events(app, status, warning):
|
||||
def test_events(app):
|
||||
def empty():
|
||||
pass
|
||||
with pytest.raises(ExtensionError) as excinfo:
|
||||
@ -73,25 +73,25 @@ def test_events(app, status, warning):
|
||||
"Callback called when disconnected"
|
||||
|
||||
|
||||
def test_emit_with_nonascii_name_node(app, status, warning):
|
||||
def test_emit_with_nonascii_name_node(app):
|
||||
node = nodes.section(names=['\u65e5\u672c\u8a9e'])
|
||||
app.emit('my_event', node)
|
||||
|
||||
|
||||
def test_extensions(app, status, warning):
|
||||
def test_extensions(app):
|
||||
app.setup_extension('shutil')
|
||||
warning = strip_colors(warning.getvalue())
|
||||
warning = strip_colors(app.warning.getvalue())
|
||||
assert "extension 'shutil' has no setup() function" in warning
|
||||
|
||||
|
||||
def test_extension_in_blacklist(app, status, warning):
|
||||
def test_extension_in_blacklist(app):
|
||||
app.setup_extension('sphinxjp.themecore')
|
||||
msg = strip_colors(warning.getvalue())
|
||||
msg = strip_colors(app.warning.getvalue())
|
||||
assert msg.startswith("WARNING: the extension 'sphinxjp.themecore' was")
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='add_source_parser')
|
||||
def test_add_source_parser(app, status, warning):
|
||||
def test_add_source_parser(app):
|
||||
assert set(app.config.source_suffix) == {'.rst', '.test'}
|
||||
|
||||
# .rst; only in :confval:`source_suffix`
|
||||
@ -105,42 +105,42 @@ def test_add_source_parser(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='extensions')
|
||||
def test_add_is_parallel_allowed(app, status, warning):
|
||||
logging.setup(app, status, warning)
|
||||
def test_add_is_parallel_allowed(app):
|
||||
logging.setup(app, app.status, app.warning)
|
||||
|
||||
assert app.is_parallel_allowed('read') is True
|
||||
assert app.is_parallel_allowed('write') is True
|
||||
assert warning.getvalue() == ''
|
||||
assert app.warning.getvalue() == ''
|
||||
|
||||
app.setup_extension('read_parallel')
|
||||
assert app.is_parallel_allowed('read') is True
|
||||
assert app.is_parallel_allowed('write') is True
|
||||
assert warning.getvalue() == ''
|
||||
assert app.warning.getvalue() == ''
|
||||
app.extensions.pop('read_parallel')
|
||||
|
||||
app.setup_extension('write_parallel')
|
||||
assert app.is_parallel_allowed('read') is False
|
||||
assert app.is_parallel_allowed('write') is True
|
||||
assert ("the write_parallel extension does not declare if it is safe "
|
||||
"for parallel reading, assuming it isn't - please ") in warning.getvalue()
|
||||
"for parallel reading, assuming it isn't - please ") in app.warning.getvalue()
|
||||
app.extensions.pop('write_parallel')
|
||||
warning.truncate(0) # reset warnings
|
||||
app.warning.truncate(0) # reset warnings
|
||||
|
||||
app.setup_extension('read_serial')
|
||||
assert app.is_parallel_allowed('read') is False
|
||||
assert "the read_serial extension is not safe for parallel reading" in warning.getvalue()
|
||||
warning.truncate(0) # reset warnings
|
||||
assert "the read_serial extension is not safe for parallel reading" in app.warning.getvalue()
|
||||
app.warning.truncate(0) # reset warnings
|
||||
assert app.is_parallel_allowed('write') is True
|
||||
assert warning.getvalue() == ''
|
||||
assert app.warning.getvalue() == ''
|
||||
app.extensions.pop('read_serial')
|
||||
|
||||
app.setup_extension('write_serial')
|
||||
assert app.is_parallel_allowed('read') is False
|
||||
assert app.is_parallel_allowed('write') is False
|
||||
assert ("the write_serial extension does not declare if it is safe "
|
||||
"for parallel reading, assuming it isn't - please ") in warning.getvalue()
|
||||
"for parallel reading, assuming it isn't - please ") in app.warning.getvalue()
|
||||
app.extensions.pop('write_serial')
|
||||
warning.truncate(0) # reset warnings
|
||||
app.warning.truncate(0) # reset warnings
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='root')
|
||||
|
@ -68,9 +68,9 @@ def test_root_doc_not_found(tmp_path, make_app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx(buildername='text', testroot='circular')
|
||||
def test_circular_toctree(app, status, warning):
|
||||
def test_circular_toctree(app):
|
||||
app.build(force_all=True)
|
||||
warnings = warning.getvalue()
|
||||
warnings = app.warning.getvalue()
|
||||
assert (
|
||||
'circular toctree references detected, ignoring: '
|
||||
'sub <- index <- sub') in warnings
|
||||
@ -80,9 +80,9 @@ def test_circular_toctree(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx(buildername='text', testroot='numbered-circular')
|
||||
def test_numbered_circular_toctree(app, status, warning):
|
||||
def test_numbered_circular_toctree(app):
|
||||
app.build(force_all=True)
|
||||
warnings = warning.getvalue()
|
||||
warnings = app.warning.getvalue()
|
||||
assert (
|
||||
'circular toctree references detected, ignoring: '
|
||||
'sub <- index <- sub') in warnings
|
||||
@ -92,7 +92,7 @@ def test_numbered_circular_toctree(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx(buildername='dummy', testroot='images')
|
||||
def test_image_glob(app, status, warning):
|
||||
def test_image_glob(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
# index.rst
|
||||
|
@ -27,8 +27,8 @@ def test_build(app):
|
||||
@pytest.mark.sphinx(
|
||||
'changes', testroot='changes', srcdir='changes-none',
|
||||
confoverrides={'version': '0.7', 'release': '0.7b1'})
|
||||
def test_no_changes(app, status):
|
||||
def test_no_changes(app):
|
||||
app.build()
|
||||
|
||||
assert 'no changes in version 0.7.' in status.getvalue()
|
||||
assert 'no changes in version 0.7.' in app.status.getvalue()
|
||||
assert not (app.outdir / 'changes.html').exists()
|
||||
|
@ -8,7 +8,7 @@ from sphinx.util.inventory import InventoryFile
|
||||
|
||||
|
||||
@pytest.mark.sphinx(buildername='dirhtml', testroot='builder-dirhtml')
|
||||
def test_dirhtml(app, status, warning):
|
||||
def test_dirhtml(app):
|
||||
app.build()
|
||||
|
||||
assert (app.outdir / 'index.html').exists()
|
||||
|
@ -351,7 +351,7 @@ def test_epub_css_files(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('epub', testroot='roles-download')
|
||||
def test_html_download_role(app, status, warning):
|
||||
def test_html_download_role(app):
|
||||
app.build()
|
||||
assert not (app.outdir / '_downloads' / 'dummy.dat').exists()
|
||||
|
||||
@ -367,9 +367,9 @@ def test_html_download_role(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('epub', testroot='toctree-duplicated')
|
||||
def test_duplicated_toctree_entry(app, status, warning):
|
||||
def test_duplicated_toctree_entry(app):
|
||||
app.build(force_all=True)
|
||||
assert 'WARNING: duplicated ToC entry found: foo.xhtml' in warning.getvalue()
|
||||
assert 'WARNING: duplicated ToC entry found: foo.xhtml' in app.warning.getvalue()
|
||||
|
||||
|
||||
@pytest.mark.skipif('DO_EPUBCHECK' not in os.environ,
|
||||
@ -402,7 +402,7 @@ def test_xml_name_pattern_check():
|
||||
|
||||
|
||||
@pytest.mark.sphinx('epub', testroot='images')
|
||||
def test_copy_images(app, status, warning):
|
||||
def test_copy_images(app):
|
||||
app.build()
|
||||
|
||||
images_dir = Path(app.outdir) / '_images'
|
||||
|
@ -178,7 +178,7 @@ def test_html_anchor_for_figure(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='directives-raw')
|
||||
def test_html_raw_directive(app, status, warning):
|
||||
def test_html_raw_directive(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
|
||||
@ -220,7 +220,7 @@ def test_alternate_stylesheets(app, cached_etree_parse, expect):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='html_style')
|
||||
def test_html_style(app, status, warning):
|
||||
def test_html_style(app):
|
||||
app.build()
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert '<link rel="stylesheet" type="text/css" href="_static/default.css" />' in result
|
||||
@ -229,7 +229,7 @@ def test_html_style(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='basic')
|
||||
def test_html_sidebar(app, status, warning):
|
||||
def test_html_sidebar(app):
|
||||
ctx = {}
|
||||
|
||||
# default for alabaster
|
||||
@ -291,7 +291,7 @@ def test_html_manpage(app, cached_etree_parse, fname, expect):
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='toctree-glob',
|
||||
confoverrides={'html_baseurl': 'https://example.com/'})
|
||||
def test_html_baseurl(app, status, warning):
|
||||
def test_html_baseurl(app):
|
||||
app.build()
|
||||
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -304,7 +304,7 @@ def test_html_baseurl(app, status, warning):
|
||||
@pytest.mark.sphinx('html', testroot='toctree-glob',
|
||||
confoverrides={'html_baseurl': 'https://example.com/subdir',
|
||||
'html_file_suffix': '.htm'})
|
||||
def test_html_baseurl_and_html_file_suffix(app, status, warning):
|
||||
def test_html_baseurl_and_html_file_suffix(app):
|
||||
app.build()
|
||||
|
||||
result = (app.outdir / 'index.htm').read_text(encoding='utf8')
|
||||
@ -369,7 +369,7 @@ def test_html_signaturereturn_icon(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root', srcdir=os.urandom(4).hex())
|
||||
def test_html_remove_sources_before_write_gh_issue_10786(app, warning):
|
||||
def test_html_remove_sources_before_write_gh_issue_10786(app):
|
||||
# see: https://github.com/sphinx-doc/sphinx/issues/10786
|
||||
target = app.srcdir / 'img.png'
|
||||
|
||||
@ -383,7 +383,7 @@ def test_html_remove_sources_before_write_gh_issue_10786(app, warning):
|
||||
app.build()
|
||||
assert not target.exists()
|
||||
|
||||
ws = strip_colors(warning.getvalue()).splitlines()
|
||||
ws = strip_colors(app.warning.getvalue()).splitlines()
|
||||
assert len(ws) >= 1
|
||||
|
||||
file = os.fsdecode(target)
|
||||
|
@ -34,7 +34,7 @@ def test_html_download(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='roles-download')
|
||||
def test_html_download_role(app, status, warning):
|
||||
def test_html_download_role(app):
|
||||
app.build()
|
||||
digest = hashlib.md5(b'dummy.dat', usedforsecurity=False).hexdigest()
|
||||
assert (app.outdir / '_downloads' / digest / 'dummy.dat').exists()
|
||||
|
@ -6,7 +6,7 @@ import pytest
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='images')
|
||||
def test_html_remote_images(app, status, warning):
|
||||
def test_html_remote_images(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -16,7 +16,7 @@ def test_html_remote_images(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='image-escape')
|
||||
def test_html_encoded_image(app, status, warning):
|
||||
def test_html_encoded_image(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -25,7 +25,7 @@ def test_html_encoded_image(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='remote-logo')
|
||||
def test_html_remote_logo(app, status, warning):
|
||||
def test_html_remote_logo(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -35,7 +35,7 @@ def test_html_remote_logo(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='local-logo')
|
||||
def test_html_local_logo(app, status, warning):
|
||||
def test_html_local_logo(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -66,7 +66,7 @@ def test_html_scaled_image_link(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='images')
|
||||
def test_copy_images(app, status, warning):
|
||||
def test_copy_images(app):
|
||||
app.build()
|
||||
|
||||
images_dir = Path(app.outdir) / '_images'
|
||||
|
@ -4,19 +4,19 @@ from sphinx.errors import ConfigError
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='basic')
|
||||
def test_default_html_math_renderer(app, status, warning):
|
||||
def test_default_html_math_renderer(app):
|
||||
assert app.builder.math_renderer_name == 'mathjax'
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='basic',
|
||||
confoverrides={'extensions': ['sphinx.ext.mathjax']})
|
||||
def test_html_math_renderer_is_mathjax(app, status, warning):
|
||||
def test_html_math_renderer_is_mathjax(app):
|
||||
assert app.builder.math_renderer_name == 'mathjax'
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='basic',
|
||||
confoverrides={'extensions': ['sphinx.ext.imgmath']})
|
||||
def test_html_math_renderer_is_imgmath(app, status, warning):
|
||||
def test_html_math_renderer_is_imgmath(app):
|
||||
assert app.builder.math_renderer_name == 'imgmath'
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ def test_html_math_renderer_is_duplicated(make_app, app_params):
|
||||
@pytest.mark.sphinx('html', testroot='basic',
|
||||
confoverrides={'extensions': ['sphinx.ext.imgmath',
|
||||
'sphinx.ext.mathjax']})
|
||||
def test_html_math_renderer_is_duplicated2(app, status, warning):
|
||||
def test_html_math_renderer_is_duplicated2(app):
|
||||
# case of both mathjax and another math_renderer is loaded
|
||||
assert app.builder.math_renderer_name == 'imgmath' # The another one is chosen
|
||||
|
||||
@ -44,7 +44,7 @@ def test_html_math_renderer_is_duplicated2(app, status, warning):
|
||||
confoverrides={'extensions': ['sphinxcontrib.jsmath',
|
||||
'sphinx.ext.imgmath'],
|
||||
'html_math_renderer': 'imgmath'})
|
||||
def test_html_math_renderer_is_chosen(app, status, warning):
|
||||
def test_html_math_renderer_is_chosen(app):
|
||||
assert app.builder.math_renderer_name == 'imgmath'
|
||||
|
||||
|
||||
|
@ -11,9 +11,9 @@ from tests.test_builders.xpath_util import check_xpath
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='numfig')
|
||||
@pytest.mark.test_params(shared_result='test_build_html_numfig')
|
||||
def test_numfig_disabled_warn(app, warning):
|
||||
def test_numfig_disabled_warn(app):
|
||||
app.build()
|
||||
warnings = warning.getvalue()
|
||||
warnings = app.warning.getvalue()
|
||||
assert 'index.rst:47: WARNING: numfig is disabled. :numref: is ignored.' in warnings
|
||||
assert 'index.rst:56: WARNING: invalid numfig_format: invalid' not in warnings
|
||||
assert 'index.rst:57: WARNING: invalid numfig_format: Fig %s %s' not in warnings
|
||||
@ -61,7 +61,7 @@ def test_numfig_disabled(app, cached_etree_parse, fname, path, check, be_found):
|
||||
'html', testroot='numfig',
|
||||
srcdir='test_numfig_without_numbered_toctree_warn',
|
||||
confoverrides={'numfig': True})
|
||||
def test_numfig_without_numbered_toctree_warn(app, warning):
|
||||
def test_numfig_without_numbered_toctree_warn(app):
|
||||
app.build()
|
||||
# remove :numbered: option
|
||||
index = (app.srcdir / 'index.rst').read_text(encoding='utf8')
|
||||
@ -69,7 +69,7 @@ def test_numfig_without_numbered_toctree_warn(app, warning):
|
||||
(app.srcdir / 'index.rst').write_text(index, encoding='utf8')
|
||||
app.build()
|
||||
|
||||
warnings = warning.getvalue()
|
||||
warnings = app.warning.getvalue()
|
||||
assert 'index.rst:47: WARNING: numfig is disabled. :numref: is ignored.' not in warnings
|
||||
assert 'index.rst:55: WARNING: Failed to create a cross reference. Any number is not assigned: index' in warnings
|
||||
assert 'index.rst:56: WARNING: invalid numfig_format: invalid' in warnings
|
||||
@ -158,9 +158,9 @@ def test_numfig_without_numbered_toctree(app, cached_etree_parse, fname, path, c
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='numfig', confoverrides={'numfig': True})
|
||||
@pytest.mark.test_params(shared_result='test_build_html_numfig_on')
|
||||
def test_numfig_with_numbered_toctree_warn(app, warning):
|
||||
def test_numfig_with_numbered_toctree_warn(app):
|
||||
app.build()
|
||||
warnings = warning.getvalue()
|
||||
warnings = app.warning.getvalue()
|
||||
assert 'index.rst:47: WARNING: numfig is disabled. :numref: is ignored.' not in warnings
|
||||
assert 'index.rst:55: WARNING: Failed to create a cross reference. Any number is not assigned: index' in warnings
|
||||
assert 'index.rst:56: WARNING: invalid numfig_format: invalid' in warnings
|
||||
@ -246,9 +246,9 @@ def test_numfig_with_numbered_toctree(app, cached_etree_parse, fname, path, chec
|
||||
'code-block': 'Code-%s',
|
||||
'section': 'SECTION-%s'}})
|
||||
@pytest.mark.test_params(shared_result='test_build_html_numfig_format_warn')
|
||||
def test_numfig_with_prefix_warn(app, warning):
|
||||
def test_numfig_with_prefix_warn(app):
|
||||
app.build()
|
||||
warnings = warning.getvalue()
|
||||
warnings = app.warning.getvalue()
|
||||
assert 'index.rst:47: WARNING: numfig is disabled. :numref: is ignored.' not in warnings
|
||||
assert 'index.rst:55: WARNING: Failed to create a cross reference. Any number is not assigned: index' in warnings
|
||||
assert 'index.rst:56: WARNING: invalid numfig_format: invalid' in warnings
|
||||
@ -335,9 +335,9 @@ def test_numfig_with_prefix(app, cached_etree_parse, fname, path, check, be_foun
|
||||
@pytest.mark.sphinx('html', testroot='numfig',
|
||||
confoverrides={'numfig': True, 'numfig_secnum_depth': 2})
|
||||
@pytest.mark.test_params(shared_result='test_build_html_numfig_depth_2')
|
||||
def test_numfig_with_secnum_depth_warn(app, warning):
|
||||
def test_numfig_with_secnum_depth_warn(app):
|
||||
app.build()
|
||||
warnings = warning.getvalue()
|
||||
warnings = app.warning.getvalue()
|
||||
assert 'index.rst:47: WARNING: numfig is disabled. :numref: is ignored.' not in warnings
|
||||
assert 'index.rst:55: WARNING: Failed to create a cross reference. Any number is not assigned: index' in warnings
|
||||
assert 'index.rst:56: WARNING: invalid numfig_format: invalid' in warnings
|
||||
|
@ -147,7 +147,7 @@ def test_build_latex_doc(app, engine, docclass, python_maximum_signature_line_le
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex')
|
||||
def test_writer(app, status, warning):
|
||||
def test_writer(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'sphinxtests.tex').read_text(encoding='utf8')
|
||||
|
||||
@ -191,12 +191,12 @@ def test_writer(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='basic')
|
||||
def test_latex_basic(app, status, warning):
|
||||
def test_latex_basic(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert r'\title{The basic Sphinx documentation for testing}' in result
|
||||
assert r'\release{}' in result
|
||||
assert r'\renewcommand{\releasename}{}' in result
|
||||
@ -206,7 +206,7 @@ def test_latex_basic(app, status, warning):
|
||||
confoverrides={
|
||||
'latex_documents': [('index', 'test.tex', 'title', 'author', 'manual')],
|
||||
})
|
||||
def test_latex_basic_manual(app, status, warning):
|
||||
def test_latex_basic_manual(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -218,7 +218,7 @@ def test_latex_basic_manual(app, status, warning):
|
||||
confoverrides={
|
||||
'latex_documents': [('index', 'test.tex', 'title', 'author', 'howto')],
|
||||
})
|
||||
def test_latex_basic_howto(app, status, warning):
|
||||
def test_latex_basic_howto(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -231,7 +231,7 @@ def test_latex_basic_howto(app, status, warning):
|
||||
'language': 'ja',
|
||||
'latex_documents': [('index', 'test.tex', 'title', 'author', 'manual')],
|
||||
})
|
||||
def test_latex_basic_manual_ja(app, status, warning):
|
||||
def test_latex_basic_manual_ja(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -244,7 +244,7 @@ def test_latex_basic_manual_ja(app, status, warning):
|
||||
'language': 'ja',
|
||||
'latex_documents': [('index', 'test.tex', 'title', 'author', 'howto')],
|
||||
})
|
||||
def test_latex_basic_howto_ja(app, status, warning):
|
||||
def test_latex_basic_howto_ja(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -253,7 +253,7 @@ def test_latex_basic_howto_ja(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='latex-theme')
|
||||
def test_latex_theme(app, status, warning):
|
||||
def test_latex_theme(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -264,7 +264,7 @@ def test_latex_theme(app, status, warning):
|
||||
@pytest.mark.sphinx('latex', testroot='latex-theme',
|
||||
confoverrides={'latex_elements': {'papersize': 'b5paper',
|
||||
'pointsize': '9pt'}})
|
||||
def test_latex_theme_papersize(app, status, warning):
|
||||
def test_latex_theme_papersize(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -275,7 +275,7 @@ def test_latex_theme_papersize(app, status, warning):
|
||||
@pytest.mark.sphinx('latex', testroot='latex-theme',
|
||||
confoverrides={'latex_theme_options': {'papersize': 'b5paper',
|
||||
'pointsize': '9pt'}})
|
||||
def test_latex_theme_options(app, status, warning):
|
||||
def test_latex_theme_options(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -284,56 +284,56 @@ 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):
|
||||
def test_latex_additional_settings_for_language_code(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert r'\usepackage{xeCJK}' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='basic', confoverrides={'language': 'el'})
|
||||
def test_latex_additional_settings_for_greek(app, status, warning):
|
||||
def test_latex_additional_settings_for_greek(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert '\\usepackage{polyglossia}\n\\setmainlanguage{greek}' in result
|
||||
assert '\\newfontfamily\\greekfonttt{FreeMono}' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='latex-title')
|
||||
def test_latex_title_after_admonitions(app, status, warning):
|
||||
def test_latex_title_after_admonitions(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert '\\title{test\\sphinxhyphen{}latex\\sphinxhyphen{}title}' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='basic',
|
||||
confoverrides={'release': '1.0_0'})
|
||||
def test_latex_release(app, status, warning):
|
||||
def test_latex_release(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert r'\release{1.0\_0}' in result
|
||||
assert r'\renewcommand{\releasename}{Release}' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='numfig',
|
||||
confoverrides={'numfig': True})
|
||||
def test_numref(app, status, warning):
|
||||
def test_numref(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert ('\\hyperref[\\detokenize{index:fig1}]'
|
||||
'{Fig.\\@ \\ref{\\detokenize{index:fig1}}}') in result
|
||||
assert ('\\hyperref[\\detokenize{baz:fig22}]'
|
||||
@ -370,12 +370,12 @@ def test_numref(app, status, warning):
|
||||
'table': 'Tab_%s',
|
||||
'code-block': 'Code-%s',
|
||||
'section': 'SECTION-%s'}})
|
||||
def test_numref_with_prefix1(app, status, warning):
|
||||
def test_numref_with_prefix1(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert '\\ref{\\detokenize{index:fig1}}' in result
|
||||
assert '\\ref{\\detokenize{baz:fig22}}' in result
|
||||
assert '\\ref{\\detokenize{index:table-1}}' in result
|
||||
@ -418,12 +418,12 @@ def test_numref_with_prefix1(app, status, warning):
|
||||
'table': 'Tab_%s:',
|
||||
'code-block': 'Code-%s | ',
|
||||
'section': 'SECTION_%s_'}})
|
||||
def test_numref_with_prefix2(app, status, warning):
|
||||
def test_numref_with_prefix2(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert ('\\hyperref[\\detokenize{index:fig1}]'
|
||||
'{Figure:\\ref{\\detokenize{index:fig1}}.\\@}') in result
|
||||
assert ('\\hyperref[\\detokenize{baz:fig22}]'
|
||||
@ -458,12 +458,12 @@ def test_numref_with_prefix2(app, status, warning):
|
||||
@pytest.mark.sphinx(
|
||||
'latex', testroot='numfig',
|
||||
confoverrides={'numfig': True, 'language': 'ja'})
|
||||
def test_numref_with_language_ja(app, status, warning):
|
||||
def test_numref_with_language_ja(app):
|
||||
app.build()
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert ('\\hyperref[\\detokenize{index:fig1}]'
|
||||
'{\u56f3 \\ref{\\detokenize{index:fig1}}}') in result
|
||||
assert ('\\hyperref[\\detokenize{baz:fig22}]'
|
||||
@ -494,7 +494,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):
|
||||
def test_latex_obey_numfig_is_false(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
result = (app.outdir / 'SphinxManual.tex').read_text(encoding='utf8')
|
||||
@ -507,7 +507,7 @@ def test_latex_obey_numfig_is_false(app, status, warning):
|
||||
@pytest.mark.sphinx(
|
||||
'latex', testroot='latex-numfig',
|
||||
confoverrides={'numfig': True, 'numfig_secnum_depth': 0})
|
||||
def test_latex_obey_numfig_secnum_depth_is_zero(app, status, warning):
|
||||
def test_latex_obey_numfig_secnum_depth_is_zero(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
result = (app.outdir / 'SphinxManual.tex').read_text(encoding='utf8')
|
||||
@ -520,7 +520,7 @@ def test_latex_obey_numfig_secnum_depth_is_zero(app, status, warning):
|
||||
@pytest.mark.sphinx(
|
||||
'latex', testroot='latex-numfig',
|
||||
confoverrides={'numfig': True, 'numfig_secnum_depth': 2})
|
||||
def test_latex_obey_numfig_secnum_depth_is_two(app, status, warning):
|
||||
def test_latex_obey_numfig_secnum_depth_is_two(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
result = (app.outdir / 'SphinxManual.tex').read_text(encoding='utf8')
|
||||
@ -533,7 +533,7 @@ def test_latex_obey_numfig_secnum_depth_is_two(app, status, warning):
|
||||
@pytest.mark.sphinx(
|
||||
'latex', testroot='latex-numfig',
|
||||
confoverrides={'numfig': True, 'math_numfig': False})
|
||||
def test_latex_obey_numfig_but_math_numfig_false(app, status, warning):
|
||||
def test_latex_obey_numfig_but_math_numfig_false(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
result = (app.outdir / 'SphinxManual.tex').read_text(encoding='utf8')
|
||||
@ -544,7 +544,7 @@ def test_latex_obey_numfig_but_math_numfig_false(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='basic')
|
||||
def test_latex_add_latex_package(app, status, warning):
|
||||
def test_latex_add_latex_package(app):
|
||||
app.add_latex_package('foo')
|
||||
app.add_latex_package('bar', 'baz')
|
||||
app.build(force_all=True)
|
||||
@ -554,12 +554,12 @@ 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):
|
||||
def test_babel_with_no_language_settings(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert '\\documentclass[letterpaper,10pt,english]{sphinxmanual}' in result
|
||||
assert '\\usepackage{babel}' in result
|
||||
assert '\\usepackage{tgtermes}' in result
|
||||
@ -579,12 +579,12 @@ def test_babel_with_no_language_settings(app, status, warning):
|
||||
@pytest.mark.sphinx(
|
||||
'latex', testroot='latex-babel',
|
||||
confoverrides={'language': 'de'})
|
||||
def test_babel_with_language_de(app, status, warning):
|
||||
def test_babel_with_language_de(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert '\\documentclass[letterpaper,10pt,ngerman]{sphinxmanual}' in result
|
||||
assert '\\usepackage{babel}' in result
|
||||
assert '\\usepackage{tgtermes}' in result
|
||||
@ -604,12 +604,12 @@ def test_babel_with_language_de(app, status, warning):
|
||||
@pytest.mark.sphinx(
|
||||
'latex', testroot='latex-babel',
|
||||
confoverrides={'language': 'ru'})
|
||||
def test_babel_with_language_ru(app, status, warning):
|
||||
def test_babel_with_language_ru(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert '\\documentclass[letterpaper,10pt,russian]{sphinxmanual}' in result
|
||||
assert '\\usepackage{babel}' in result
|
||||
assert '\\usepackage{tgtermes}' not in result
|
||||
@ -629,12 +629,12 @@ def test_babel_with_language_ru(app, status, warning):
|
||||
@pytest.mark.sphinx(
|
||||
'latex', testroot='latex-babel',
|
||||
confoverrides={'language': 'tr'})
|
||||
def test_babel_with_language_tr(app, status, warning):
|
||||
def test_babel_with_language_tr(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert '\\documentclass[letterpaper,10pt,turkish]{sphinxmanual}' in result
|
||||
assert '\\usepackage{babel}' in result
|
||||
assert '\\usepackage{tgtermes}' in result
|
||||
@ -654,12 +654,12 @@ def test_babel_with_language_tr(app, status, warning):
|
||||
@pytest.mark.sphinx(
|
||||
'latex', testroot='latex-babel',
|
||||
confoverrides={'language': 'ja'})
|
||||
def test_babel_with_language_ja(app, status, warning):
|
||||
def test_babel_with_language_ja(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert '\\documentclass[letterpaper,10pt,dvipdfmx]{sphinxmanual}' in result
|
||||
assert '\\usepackage{babel}' not in result
|
||||
assert '\\usepackage{tgtermes}' in result
|
||||
@ -678,12 +678,12 @@ def test_babel_with_language_ja(app, status, warning):
|
||||
@pytest.mark.sphinx(
|
||||
'latex', testroot='latex-babel',
|
||||
confoverrides={'language': 'unknown'})
|
||||
def test_babel_with_unknown_language(app, status, warning):
|
||||
def test_babel_with_unknown_language(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert '\\documentclass[letterpaper,10pt,english]{sphinxmanual}' in result
|
||||
assert '\\usepackage{babel}' in result
|
||||
assert '\\usepackage{tgtermes}' in result
|
||||
@ -692,7 +692,7 @@ def test_babel_with_unknown_language(app, status, warning):
|
||||
in result)
|
||||
assert '\\shorthandoff' in result
|
||||
|
||||
assert "WARNING: no Babel option known for language 'unknown'" in warning.getvalue()
|
||||
assert "WARNING: no Babel option known for language 'unknown'" in app.warning.getvalue()
|
||||
|
||||
# sphinxmessages.sty
|
||||
result = (app.outdir / 'sphinxmessages.sty').read_text(encoding='utf8')
|
||||
@ -705,12 +705,12 @@ def test_babel_with_unknown_language(app, status, warning):
|
||||
@pytest.mark.sphinx(
|
||||
'latex', testroot='latex-babel',
|
||||
confoverrides={'language': 'de', 'latex_engine': 'lualatex'})
|
||||
def test_polyglossia_with_language_de(app, status, warning):
|
||||
def test_polyglossia_with_language_de(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert '\\documentclass[letterpaper,10pt,german]{sphinxmanual}' in result
|
||||
assert '\\usepackage{polyglossia}' in result
|
||||
assert '\\setmainlanguage[spelling=new]{german}' in result
|
||||
@ -731,12 +731,12 @@ def test_polyglossia_with_language_de(app, status, warning):
|
||||
@pytest.mark.sphinx(
|
||||
'latex', testroot='latex-babel',
|
||||
confoverrides={'language': 'de-1901', 'latex_engine': 'lualatex'})
|
||||
def test_polyglossia_with_language_de_1901(app, status, warning):
|
||||
def test_polyglossia_with_language_de_1901(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert '\\documentclass[letterpaper,10pt,german]{sphinxmanual}' in result
|
||||
assert '\\usepackage{polyglossia}' in result
|
||||
assert '\\setmainlanguage[spelling=old]{german}' in result
|
||||
@ -755,12 +755,12 @@ def test_polyglossia_with_language_de_1901(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex')
|
||||
def test_footnote(app, status, warning):
|
||||
def test_footnote(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'sphinxtests.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert ('\\sphinxAtStartPar\n%\n\\begin{footnote}[1]\\sphinxAtStartFootnote\n'
|
||||
'numbered\n%\n\\end{footnote}') in result
|
||||
assert ('\\begin{footnote}[2]\\sphinxAtStartFootnote\nauto numbered\n%\n'
|
||||
@ -784,12 +784,12 @@ def test_footnote(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='footnotes')
|
||||
def test_reference_in_caption_and_codeblock_in_footnote(app, status, warning):
|
||||
def test_reference_in_caption_and_codeblock_in_footnote(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert ('\\caption{This is the figure caption with a reference to '
|
||||
'\\sphinxcite{index:authoryear}.}' in result)
|
||||
assert '\\chapter{The section with a reference to {[}AuthorYear{]}}' in result
|
||||
@ -824,12 +824,12 @@ 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):
|
||||
def test_footnote_referred_multiple_times(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
|
||||
assert ('Explicitly numbered footnote: %\n'
|
||||
'\\begin{footnote}[100]'
|
||||
@ -846,12 +846,12 @@ def test_footnote_referred_multiple_times(app, status, warning):
|
||||
@pytest.mark.sphinx(
|
||||
'latex', testroot='footnotes',
|
||||
confoverrides={'latex_show_urls': 'inline'})
|
||||
def test_latex_show_urls_is_inline(app, status, warning):
|
||||
def test_latex_show_urls_is_inline(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert ('Same footnote number %\n'
|
||||
'\\begin{footnote}[1]\\sphinxAtStartFootnote\n'
|
||||
'footnote in bar\n%\n\\end{footnote} in bar.rst') in result
|
||||
@ -903,12 +903,12 @@ def test_latex_show_urls_is_inline(app, status, warning):
|
||||
@pytest.mark.sphinx(
|
||||
'latex', testroot='footnotes',
|
||||
confoverrides={'latex_show_urls': 'footnote'})
|
||||
def test_latex_show_urls_is_footnote(app, status, warning):
|
||||
def test_latex_show_urls_is_footnote(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert ('Same footnote number %\n'
|
||||
'\\begin{footnote}[1]\\sphinxAtStartFootnote\n'
|
||||
'footnote in bar\n%\n\\end{footnote} in bar.rst') in result
|
||||
@ -965,12 +965,12 @@ def test_latex_show_urls_is_footnote(app, status, warning):
|
||||
@pytest.mark.sphinx(
|
||||
'latex', testroot='footnotes',
|
||||
confoverrides={'latex_show_urls': 'no'})
|
||||
def test_latex_show_urls_is_no(app, status, warning):
|
||||
def test_latex_show_urls_is_no(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert ('Same footnote number %\n'
|
||||
'\\begin{footnote}[1]\\sphinxAtStartFootnote\n'
|
||||
'footnote in bar\n%\n\\end{footnote} in bar.rst') in result
|
||||
@ -1014,18 +1014,18 @@ def test_latex_show_urls_is_no(app, status, warning):
|
||||
'latex', testroot='footnotes',
|
||||
confoverrides={'latex_show_urls': 'footnote',
|
||||
'rst_prolog': '.. |URL| replace:: `text <https://www.example.com/>`__'})
|
||||
def test_latex_show_urls_footnote_and_substitutions(app, status, warning):
|
||||
def test_latex_show_urls_footnote_and_substitutions(app):
|
||||
# hyperlinks in substitutions should not effect to make footnotes (refs: #4784)
|
||||
test_latex_show_urls_is_footnote(app, status, warning)
|
||||
test_latex_show_urls_is_footnote(app)
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='image-in-section')
|
||||
def test_image_in_section(app, status, warning):
|
||||
def test_image_in_section(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert ('\\chapter[Test section]{\\lowercase{\\sphinxincludegraphics'
|
||||
'[width=15bp,height=15bp]}{{pic}.png} Test section}'
|
||||
in result)
|
||||
@ -1037,18 +1037,18 @@ def test_image_in_section(app, status, warning):
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='basic',
|
||||
confoverrides={'latex_logo': 'notfound.jpg'})
|
||||
def test_latex_logo_if_not_found(app, status, warning):
|
||||
def test_latex_logo_if_not_found(app):
|
||||
with pytest.raises(SphinxError):
|
||||
app.build(force_all=True)
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='toctree-maxdepth')
|
||||
def test_toctree_maxdepth_manual(app, status, warning):
|
||||
def test_toctree_maxdepth_manual(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert '\\setcounter{tocdepth}{1}' in result
|
||||
assert '\\setcounter{secnumdepth}' not in result
|
||||
assert '\\chapter{Foo}' in result
|
||||
@ -1060,12 +1060,12 @@ def test_toctree_maxdepth_manual(app, status, warning):
|
||||
('index', 'projectnamenotset.tex', 'Sphinx Tests Documentation',
|
||||
'Georg Brandl', 'howto'),
|
||||
]})
|
||||
def test_toctree_maxdepth_howto(app, status, warning):
|
||||
def test_toctree_maxdepth_howto(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert '\\setcounter{tocdepth}{2}' in result
|
||||
assert '\\setcounter{secnumdepth}' not in result
|
||||
assert '\\section{Foo}' in result
|
||||
@ -1074,12 +1074,12 @@ def test_toctree_maxdepth_howto(app, status, warning):
|
||||
@pytest.mark.sphinx(
|
||||
'latex', testroot='toctree-maxdepth',
|
||||
confoverrides={'root_doc': 'foo'})
|
||||
def test_toctree_not_found(app, status, warning):
|
||||
def test_toctree_not_found(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert '\\setcounter{tocdepth}' not in result
|
||||
assert '\\setcounter{secnumdepth}' not in result
|
||||
assert '\\chapter{Foo A}' in result
|
||||
@ -1088,12 +1088,12 @@ def test_toctree_not_found(app, status, warning):
|
||||
@pytest.mark.sphinx(
|
||||
'latex', testroot='toctree-maxdepth',
|
||||
confoverrides={'root_doc': 'bar'})
|
||||
def test_toctree_without_maxdepth(app, status, warning):
|
||||
def test_toctree_without_maxdepth(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert '\\setcounter{tocdepth}' not in result
|
||||
assert '\\setcounter{secnumdepth}' not in result
|
||||
|
||||
@ -1101,12 +1101,12 @@ def test_toctree_without_maxdepth(app, status, warning):
|
||||
@pytest.mark.sphinx(
|
||||
'latex', testroot='toctree-maxdepth',
|
||||
confoverrides={'root_doc': 'qux'})
|
||||
def test_toctree_with_deeper_maxdepth(app, status, warning):
|
||||
def test_toctree_with_deeper_maxdepth(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert '\\setcounter{tocdepth}{3}' in result
|
||||
assert '\\setcounter{secnumdepth}{3}' in result
|
||||
|
||||
@ -1114,24 +1114,24 @@ def test_toctree_with_deeper_maxdepth(app, status, warning):
|
||||
@pytest.mark.sphinx(
|
||||
'latex', testroot='toctree-maxdepth',
|
||||
confoverrides={'latex_toplevel_sectioning': None})
|
||||
def test_latex_toplevel_sectioning_is_None(app, status, warning):
|
||||
def test_latex_toplevel_sectioning_is_None(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert '\\chapter{Foo}' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
'latex', testroot='toctree-maxdepth',
|
||||
confoverrides={'latex_toplevel_sectioning': 'part'})
|
||||
def test_latex_toplevel_sectioning_is_part(app, status, warning):
|
||||
def test_latex_toplevel_sectioning_is_part(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert '\\part{Foo}' in result
|
||||
assert '\\chapter{Foo A}' in result
|
||||
assert '\\chapter{Foo B}' in result
|
||||
@ -1144,12 +1144,12 @@ def test_latex_toplevel_sectioning_is_part(app, status, warning):
|
||||
('index', 'projectnamenotset.tex', 'Sphinx Tests Documentation',
|
||||
'Georg Brandl', 'howto'),
|
||||
]})
|
||||
def test_latex_toplevel_sectioning_is_part_with_howto(app, status, warning):
|
||||
def test_latex_toplevel_sectioning_is_part_with_howto(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert '\\part{Foo}' in result
|
||||
assert '\\section{Foo A}' in result
|
||||
assert '\\section{Foo B}' in result
|
||||
@ -1158,12 +1158,12 @@ def test_latex_toplevel_sectioning_is_part_with_howto(app, status, warning):
|
||||
@pytest.mark.sphinx(
|
||||
'latex', testroot='toctree-maxdepth',
|
||||
confoverrides={'latex_toplevel_sectioning': 'chapter'})
|
||||
def test_latex_toplevel_sectioning_is_chapter(app, status, warning):
|
||||
def test_latex_toplevel_sectioning_is_chapter(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert '\\chapter{Foo}' in result
|
||||
|
||||
|
||||
@ -1174,42 +1174,42 @@ def test_latex_toplevel_sectioning_is_chapter(app, status, warning):
|
||||
('index', 'projectnamenotset.tex', 'Sphinx Tests Documentation',
|
||||
'Georg Brandl', 'howto'),
|
||||
]})
|
||||
def test_latex_toplevel_sectioning_is_chapter_with_howto(app, status, warning):
|
||||
def test_latex_toplevel_sectioning_is_chapter_with_howto(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert '\\section{Foo}' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
'latex', testroot='toctree-maxdepth',
|
||||
confoverrides={'latex_toplevel_sectioning': 'section'})
|
||||
def test_latex_toplevel_sectioning_is_section(app, status, warning):
|
||||
def test_latex_toplevel_sectioning_is_section(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert '\\section{Foo}' in result
|
||||
|
||||
|
||||
@skip_if_stylefiles_notfound
|
||||
@pytest.mark.sphinx('latex', testroot='maxlistdepth')
|
||||
def test_maxlistdepth_at_ten(app, status, warning):
|
||||
def test_maxlistdepth_at_ten(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
compile_latex_document(app, 'projectnamenotset.tex')
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='latex-table',
|
||||
confoverrides={'latex_table_style': []})
|
||||
@pytest.mark.test_params(shared_result='latex-table')
|
||||
def test_latex_table_tabulars(app, status, warning):
|
||||
def test_latex_table_tabulars(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
tables = {}
|
||||
@ -1280,7 +1280,7 @@ def test_latex_table_tabulars(app, status, warning):
|
||||
@pytest.mark.sphinx('latex', testroot='latex-table',
|
||||
confoverrides={'latex_table_style': []})
|
||||
@pytest.mark.test_params(shared_result='latex-table')
|
||||
def test_latex_table_longtable(app, status, warning):
|
||||
def test_latex_table_longtable(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
tables = {}
|
||||
@ -1341,7 +1341,7 @@ def test_latex_table_longtable(app, status, warning):
|
||||
@pytest.mark.sphinx('latex', testroot='latex-table',
|
||||
confoverrides={'latex_table_style': []})
|
||||
@pytest.mark.test_params(shared_result='latex-table')
|
||||
def test_latex_table_complex_tables(app, status, warning):
|
||||
def test_latex_table_complex_tables(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
tables = {}
|
||||
@ -1371,7 +1371,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):
|
||||
def test_latex_table_with_booktabs_and_colorrows(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
assert r'\PassOptionsToPackage{booktabs}{sphinx}' in result
|
||||
@ -1387,7 +1387,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):
|
||||
def test_latex_table_custom_template_caseA(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
assert 'SALUT LES COPAINS' in result
|
||||
@ -1396,7 +1396,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):
|
||||
def test_latex_table_custom_template_caseB(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
assert 'SALUT LES COPAINS' not in result
|
||||
@ -1404,14 +1404,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):
|
||||
def test_latex_table_custom_template_caseC(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.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):
|
||||
def test_latex_raw_directive(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
|
||||
@ -1426,7 +1426,7 @@ def test_latex_raw_directive(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='images')
|
||||
def test_latex_images(app, status, warning):
|
||||
def test_latex_images(app):
|
||||
with http_server(RemoteImageHandler, port=7777):
|
||||
app.build(force_all=True)
|
||||
|
||||
@ -1439,7 +1439,7 @@ def test_latex_images(app, status, warning):
|
||||
# not found images
|
||||
assert '\\sphinxincludegraphics{{NOT_EXIST}.PNG}' not in result
|
||||
assert ('WARNING: Could not fetch remote image: '
|
||||
'http://localhost:7777/NOT_EXIST.PNG [404]' in warning.getvalue())
|
||||
'http://localhost:7777/NOT_EXIST.PNG [404]' in app.warning.getvalue())
|
||||
|
||||
# an image having target
|
||||
assert ('\\sphinxhref{https://www.sphinx-doc.org/}'
|
||||
@ -1451,7 +1451,7 @@ def test_latex_images(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='latex-index')
|
||||
def test_latex_index(app, status, warning):
|
||||
def test_latex_index(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
@ -1465,7 +1465,7 @@ def test_latex_index(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='latex-equations')
|
||||
def test_latex_equations(app, status, warning):
|
||||
def test_latex_equations(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
@ -1475,7 +1475,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):
|
||||
def test_latex_image_in_parsed_literal(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
@ -1485,7 +1485,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):
|
||||
def test_latex_nested_enumerated_list(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
@ -1502,7 +1502,7 @@ def test_latex_nested_enumerated_list(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='footnotes')
|
||||
def test_latex_thebibliography(app, status, warning):
|
||||
def test_latex_thebibliography(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
@ -1515,7 +1515,7 @@ def test_latex_thebibliography(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='glossary')
|
||||
def test_latex_glossary(app, status, warning):
|
||||
def test_latex_glossary(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
@ -1539,7 +1539,7 @@ def test_latex_glossary(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='latex-labels')
|
||||
def test_latex_labels(app, status, warning):
|
||||
def test_latex_labels(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
@ -1588,7 +1588,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):
|
||||
def test_latex_figure_in_admonition(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
assert 'tabulary' not in result
|
||||
@ -1612,15 +1612,15 @@ def test_default_latex_documents():
|
||||
@skip_if_requested
|
||||
@skip_if_stylefiles_notfound
|
||||
@pytest.mark.sphinx('latex', testroot='latex-includegraphics')
|
||||
def test_includegraphics_oversized(app, status, warning):
|
||||
def test_includegraphics_oversized(app):
|
||||
app.build(force_all=True)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
compile_latex_document(app)
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='index_on_title')
|
||||
def test_index_on_title(app, status, warning):
|
||||
def test_index_on_title(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
assert ('\\chapter{Test for index in top level title}\n'
|
||||
@ -1631,7 +1631,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):
|
||||
def test_texescape_for_non_unicode_supported_engine(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -1643,7 +1643,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):
|
||||
def test_texescape_for_unicode_supported_engine(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -1655,20 +1655,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):
|
||||
def test_latex_elements_extrapackages(app):
|
||||
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):
|
||||
def test_latex_nested_tables(app):
|
||||
app.build(force_all=True)
|
||||
assert warning.getvalue() == ''
|
||||
assert app.warning.getvalue() == ''
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='latex-container')
|
||||
def test_latex_container(app, status, warning):
|
||||
def test_latex_container(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
assert r'\begin{sphinxuseclass}{classname}' in result
|
||||
@ -1703,7 +1703,7 @@ def test_latex_code_role(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='images')
|
||||
def test_copy_images(app, status, warning):
|
||||
def test_copy_images(app):
|
||||
app.build()
|
||||
|
||||
test_dir = Path(app.outdir)
|
||||
@ -1721,7 +1721,7 @@ def test_copy_images(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='latex-labels-before-module')
|
||||
def test_duplicated_labels_before_module(app, status, warning):
|
||||
def test_duplicated_labels_before_module(app):
|
||||
app.build()
|
||||
content: str = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
|
||||
@ -1752,7 +1752,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):
|
||||
def test_one_parameter_per_line(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
|
||||
|
@ -37,12 +37,11 @@ ts_re = re.compile(r".*\[(?P<ts>.*)\].*")
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Callable, Iterable
|
||||
from io import StringIO
|
||||
from typing import Any
|
||||
|
||||
from urllib3 import HTTPConnectionPool
|
||||
|
||||
from sphinx.application import Sphinx
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
class DefaultsHandler(BaseHTTPRequestHandler):
|
||||
@ -112,7 +111,7 @@ class ConnectionMeasurement:
|
||||
|
||||
|
||||
@pytest.mark.sphinx('linkcheck', testroot='linkcheck', freshenv=True)
|
||||
def test_defaults(app: Sphinx) -> None:
|
||||
def test_defaults(app: SphinxTestApp) -> None:
|
||||
with serve_application(app, DefaultsHandler) as address:
|
||||
with ConnectionMeasurement() as m:
|
||||
app.build()
|
||||
@ -189,7 +188,7 @@ def test_defaults(app: Sphinx) -> None:
|
||||
@pytest.mark.sphinx(
|
||||
'linkcheck', testroot='linkcheck', freshenv=True,
|
||||
confoverrides={'linkcheck_anchors': False})
|
||||
def test_check_link_response_only(app: Sphinx) -> None:
|
||||
def test_check_link_response_only(app: SphinxTestApp) -> None:
|
||||
with serve_application(app, DefaultsHandler) as address:
|
||||
app.build()
|
||||
|
||||
@ -203,7 +202,7 @@ def test_check_link_response_only(app: Sphinx) -> None:
|
||||
|
||||
|
||||
@pytest.mark.sphinx('linkcheck', testroot='linkcheck-too-many-retries', freshenv=True)
|
||||
def test_too_many_retries(app: Sphinx) -> None:
|
||||
def test_too_many_retries(app: SphinxTestApp) -> None:
|
||||
with serve_application(app, DefaultsHandler) as address:
|
||||
app.build()
|
||||
|
||||
@ -232,7 +231,7 @@ def test_too_many_retries(app: Sphinx) -> None:
|
||||
|
||||
|
||||
@pytest.mark.sphinx('linkcheck', testroot='linkcheck-raw-node', freshenv=True)
|
||||
def test_raw_node(app: Sphinx) -> None:
|
||||
def test_raw_node(app: SphinxTestApp) -> None:
|
||||
with serve_application(app, OKHandler) as address:
|
||||
# write an index file that contains a link back to this webserver's root
|
||||
# URL. docutils will replace the raw node with the contents retrieved..
|
||||
@ -265,7 +264,7 @@ def test_raw_node(app: Sphinx) -> None:
|
||||
@pytest.mark.sphinx(
|
||||
'linkcheck', testroot='linkcheck-anchors-ignore', freshenv=True,
|
||||
confoverrides={'linkcheck_anchors_ignore': ["^!", "^top$"]})
|
||||
def test_anchors_ignored(app: Sphinx) -> None:
|
||||
def test_anchors_ignored(app: SphinxTestApp) -> None:
|
||||
with serve_application(app, OKHandler):
|
||||
app.build()
|
||||
|
||||
@ -337,7 +336,7 @@ class AnchorsIgnoreForUrlHandler(BaseHTTPRequestHandler):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('linkcheck', testroot='linkcheck-anchors-ignore-for-url', freshenv=True)
|
||||
def test_anchors_ignored_for_url(app: Sphinx) -> None:
|
||||
def test_anchors_ignored_for_url(app: SphinxTestApp) -> None:
|
||||
with serve_application(app, AnchorsIgnoreForUrlHandler) as address:
|
||||
app.config.linkcheck_anchors_ignore_for_url = [
|
||||
f'http://{address}/ignored', # existing page
|
||||
@ -379,7 +378,7 @@ def test_anchors_ignored_for_url(app: Sphinx) -> None:
|
||||
|
||||
|
||||
@pytest.mark.sphinx('linkcheck', testroot='linkcheck-localserver-anchor', freshenv=True)
|
||||
def test_raises_for_invalid_status(app: Sphinx) -> None:
|
||||
def test_raises_for_invalid_status(app: SphinxTestApp) -> None:
|
||||
class InternalServerErrorHandler(BaseHTTPRequestHandler):
|
||||
protocol_version = "HTTP/1.1"
|
||||
|
||||
@ -494,7 +493,7 @@ def custom_handler(
|
||||
|
||||
|
||||
@pytest.mark.sphinx('linkcheck', testroot='linkcheck-localserver', freshenv=True)
|
||||
def test_auth_header_uses_first_match(app: Sphinx) -> None:
|
||||
def test_auth_header_uses_first_match(app: SphinxTestApp) -> None:
|
||||
with serve_application(app, custom_handler(valid_credentials=("user1", "password"))) as address:
|
||||
app.config.linkcheck_auth = [
|
||||
(r'^$', ('no', 'match')),
|
||||
@ -512,7 +511,7 @@ def test_auth_header_uses_first_match(app: Sphinx) -> None:
|
||||
@pytest.mark.sphinx(
|
||||
'linkcheck', testroot='linkcheck-localserver', freshenv=True,
|
||||
confoverrides={'linkcheck_allow_unauthorized': False})
|
||||
def test_unauthorized_broken(app: Sphinx) -> None:
|
||||
def test_unauthorized_broken(app: SphinxTestApp) -> None:
|
||||
with serve_application(app, custom_handler(valid_credentials=("user1", "password"))):
|
||||
app.build()
|
||||
|
||||
@ -526,7 +525,7 @@ def test_unauthorized_broken(app: Sphinx) -> None:
|
||||
@pytest.mark.sphinx(
|
||||
'linkcheck', testroot='linkcheck-localserver', freshenv=True,
|
||||
confoverrides={'linkcheck_auth': [(r'^$', ('user1', 'password'))]})
|
||||
def test_auth_header_no_match(app: Sphinx) -> None:
|
||||
def test_auth_header_no_match(app: SphinxTestApp) -> None:
|
||||
with serve_application(app, custom_handler(valid_credentials=("user1", "password"))):
|
||||
app.build()
|
||||
|
||||
@ -538,7 +537,7 @@ def test_auth_header_no_match(app: Sphinx) -> None:
|
||||
|
||||
|
||||
@pytest.mark.sphinx('linkcheck', testroot='linkcheck-localserver', freshenv=True)
|
||||
def test_linkcheck_request_headers(app: Sphinx) -> None:
|
||||
def test_linkcheck_request_headers(app: SphinxTestApp) -> None:
|
||||
def check_headers(self):
|
||||
if "X-Secret" in self.headers:
|
||||
return False
|
||||
@ -558,7 +557,7 @@ def test_linkcheck_request_headers(app: Sphinx) -> None:
|
||||
|
||||
|
||||
@pytest.mark.sphinx('linkcheck', testroot='linkcheck-localserver', freshenv=True)
|
||||
def test_linkcheck_request_headers_no_slash(app: Sphinx) -> None:
|
||||
def test_linkcheck_request_headers_no_slash(app: SphinxTestApp) -> None:
|
||||
def check_headers(self):
|
||||
if "X-Secret" in self.headers:
|
||||
return False
|
||||
@ -583,7 +582,7 @@ def test_linkcheck_request_headers_no_slash(app: Sphinx) -> None:
|
||||
"http://do.not.match.org": {"Accept": "application/json"},
|
||||
"*": {"X-Secret": "open sesami"},
|
||||
}})
|
||||
def test_linkcheck_request_headers_default(app: Sphinx) -> None:
|
||||
def test_linkcheck_request_headers_default(app: SphinxTestApp) -> None:
|
||||
def check_headers(self):
|
||||
if self.headers["X-Secret"] != "open sesami":
|
||||
return False
|
||||
@ -627,7 +626,7 @@ def make_redirect_handler(*, support_head: bool) -> type[BaseHTTPRequestHandler]
|
||||
|
||||
|
||||
@pytest.mark.sphinx('linkcheck', testroot='linkcheck-localserver', freshenv=True)
|
||||
def test_follows_redirects_on_HEAD(app, capsys, warning):
|
||||
def test_follows_redirects_on_HEAD(app, capsys):
|
||||
with serve_application(app, make_redirect_handler(support_head=True)) as address:
|
||||
app.build()
|
||||
stdout, stderr = capsys.readouterr()
|
||||
@ -642,11 +641,11 @@ def test_follows_redirects_on_HEAD(app, capsys, warning):
|
||||
127.0.0.1 - - [] "HEAD /?redirected=1 HTTP/1.1" 204 -
|
||||
""",
|
||||
)
|
||||
assert warning.getvalue() == ''
|
||||
assert app.warning.getvalue() == ''
|
||||
|
||||
|
||||
@pytest.mark.sphinx('linkcheck', testroot='linkcheck-localserver', freshenv=True)
|
||||
def test_follows_redirects_on_GET(app, capsys, warning):
|
||||
def test_follows_redirects_on_GET(app, capsys):
|
||||
with serve_application(app, make_redirect_handler(support_head=False)) as address:
|
||||
app.build()
|
||||
stdout, stderr = capsys.readouterr()
|
||||
@ -662,11 +661,11 @@ def test_follows_redirects_on_GET(app, capsys, warning):
|
||||
127.0.0.1 - - [] "GET /?redirected=1 HTTP/1.1" 204 -
|
||||
""",
|
||||
)
|
||||
assert warning.getvalue() == ''
|
||||
assert app.warning.getvalue() == ''
|
||||
|
||||
|
||||
@pytest.mark.sphinx('linkcheck', testroot='linkcheck-localserver-warn-redirects')
|
||||
def test_linkcheck_allowed_redirects(app: Sphinx, warning: StringIO) -> None:
|
||||
def test_linkcheck_allowed_redirects(app: SphinxTestApp) -> None:
|
||||
with serve_application(app, make_redirect_handler(support_head=False)) as address:
|
||||
app.config.linkcheck_allowed_redirects = {f'http://{address}/.*1': '.*'}
|
||||
compile_linkcheck_allowed_redirects(app, app.config)
|
||||
@ -688,8 +687,8 @@ def test_linkcheck_allowed_redirects(app: Sphinx, warning: StringIO) -> None:
|
||||
}
|
||||
|
||||
assert (f"index.rst:3: WARNING: redirect http://{address}/path2 - with Found to "
|
||||
f"http://{address}/?redirected=1\n" in strip_colors(warning.getvalue()))
|
||||
assert len(warning.getvalue().splitlines()) == 1
|
||||
f"http://{address}/?redirected=1\n" in strip_colors(app.warning.getvalue()))
|
||||
assert len(app.warning.getvalue().splitlines()) == 1
|
||||
|
||||
|
||||
class OKHandler(BaseHTTPRequestHandler):
|
||||
@ -726,7 +725,7 @@ def test_invalid_ssl(get_request, app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('linkcheck', testroot='linkcheck-localserver-https', freshenv=True)
|
||||
def test_connect_to_selfsigned_fails(app: Sphinx) -> None:
|
||||
def test_connect_to_selfsigned_fails(app: SphinxTestApp) -> None:
|
||||
with serve_application(app, OKHandler, tls_enabled=True) as address:
|
||||
app.build()
|
||||
|
||||
@ -741,7 +740,7 @@ def test_connect_to_selfsigned_fails(app: Sphinx) -> None:
|
||||
|
||||
@pytest.mark.sphinx('linkcheck', testroot='linkcheck-localserver-https', freshenv=True,
|
||||
confoverrides={'tls_verify': False})
|
||||
def test_connect_to_selfsigned_with_tls_verify_false(app: Sphinx) -> None:
|
||||
def test_connect_to_selfsigned_with_tls_verify_false(app: SphinxTestApp) -> None:
|
||||
with serve_application(app, OKHandler, tls_enabled=True) as address:
|
||||
app.build()
|
||||
|
||||
@ -759,7 +758,7 @@ def test_connect_to_selfsigned_with_tls_verify_false(app: Sphinx) -> None:
|
||||
|
||||
@pytest.mark.sphinx('linkcheck', testroot='linkcheck-localserver-https', freshenv=True,
|
||||
confoverrides={'tls_cacerts': CERT_FILE})
|
||||
def test_connect_to_selfsigned_with_tls_cacerts(app: Sphinx) -> None:
|
||||
def test_connect_to_selfsigned_with_tls_cacerts(app: SphinxTestApp) -> None:
|
||||
with serve_application(app, OKHandler, tls_enabled=True) as address:
|
||||
app.build()
|
||||
|
||||
@ -795,7 +794,7 @@ def test_connect_to_selfsigned_with_requests_env_var(monkeypatch, app):
|
||||
|
||||
@pytest.mark.sphinx('linkcheck', testroot='linkcheck-localserver-https', freshenv=True,
|
||||
confoverrides={'tls_cacerts': "does/not/exist"})
|
||||
def test_connect_to_selfsigned_nonexistent_cert_file(app: Sphinx) -> None:
|
||||
def test_connect_to_selfsigned_nonexistent_cert_file(app: SphinxTestApp) -> None:
|
||||
with serve_application(app, OKHandler, tls_enabled=True) as address:
|
||||
app.build()
|
||||
|
||||
@ -870,7 +869,7 @@ def make_retry_after_handler(responses: list[tuple[int, str | None]]) -> type[Ba
|
||||
|
||||
|
||||
@pytest.mark.sphinx('linkcheck', testroot='linkcheck-localserver', freshenv=True)
|
||||
def test_too_many_requests_retry_after_int_delay(app, capsys, status):
|
||||
def test_too_many_requests_retry_after_int_delay(app, capsys):
|
||||
with (
|
||||
serve_application(app, make_retry_after_handler([(429, "0"), (200, None)])) as address,
|
||||
mock.patch("sphinx.builders.linkcheck.DEFAULT_DELAY", 0),
|
||||
@ -887,7 +886,7 @@ def test_too_many_requests_retry_after_int_delay(app, capsys, status):
|
||||
"info": "",
|
||||
}
|
||||
rate_limit_log = f"-rate limited- http://{address}/ | sleeping...\n"
|
||||
assert rate_limit_log in strip_colors(status.getvalue())
|
||||
assert rate_limit_log in strip_colors(app.status.getvalue())
|
||||
_stdout, stderr = capsys.readouterr()
|
||||
assert stderr == textwrap.dedent(
|
||||
"""\
|
||||
@ -963,7 +962,7 @@ def test_too_many_requests_retry_after_without_header(app, capsys):
|
||||
'linkcheck_timeout': 0.01,
|
||||
}
|
||||
)
|
||||
def test_requests_timeout(app: Sphinx) -> None:
|
||||
def test_requests_timeout(app: SphinxTestApp) -> None:
|
||||
class DelayedResponseHandler(BaseHTTPRequestHandler):
|
||||
protocol_version = "HTTP/1.1"
|
||||
|
||||
@ -984,7 +983,7 @@ def test_requests_timeout(app: Sphinx) -> None:
|
||||
|
||||
@pytest.mark.sphinx('linkcheck', testroot='linkcheck-localserver', freshenv=True,
|
||||
confoverrides={'linkcheck_rate_limit_timeout': 0.0})
|
||||
def test_too_many_requests_user_timeout(app: Sphinx) -> None:
|
||||
def test_too_many_requests_user_timeout(app: SphinxTestApp) -> None:
|
||||
with serve_application(app, make_retry_after_handler([(429, None)])) as address:
|
||||
app.build()
|
||||
content = (app.outdir / 'output.json').read_text(encoding='utf8')
|
||||
@ -1003,7 +1002,7 @@ class FakeResponse:
|
||||
url = "http://localhost/"
|
||||
|
||||
|
||||
def test_limit_rate_default_sleep(app: Sphinx) -> None:
|
||||
def test_limit_rate_default_sleep(app: SphinxTestApp) -> None:
|
||||
worker = HyperlinkAvailabilityCheckWorker(app.config, Queue(), Queue(), {})
|
||||
with mock.patch('time.time', return_value=0.0):
|
||||
next_check = worker.limit_rate(FakeResponse.url, FakeResponse.headers.get("Retry-After"))
|
||||
@ -1011,13 +1010,13 @@ def test_limit_rate_default_sleep(app: Sphinx) -> None:
|
||||
|
||||
|
||||
@pytest.mark.sphinx(confoverrides={'linkcheck_rate_limit_timeout': 0.0})
|
||||
def test_limit_rate_user_max_delay(app: Sphinx) -> None:
|
||||
def test_limit_rate_user_max_delay(app: SphinxTestApp) -> None:
|
||||
worker = HyperlinkAvailabilityCheckWorker(app.config, Queue(), Queue(), {})
|
||||
next_check = worker.limit_rate(FakeResponse.url, FakeResponse.headers.get("Retry-After"))
|
||||
assert next_check is None
|
||||
|
||||
|
||||
def test_limit_rate_doubles_previous_wait_time(app: Sphinx) -> None:
|
||||
def test_limit_rate_doubles_previous_wait_time(app: SphinxTestApp) -> None:
|
||||
rate_limits = {"localhost": RateLimit(60.0, 0.0)}
|
||||
worker = HyperlinkAvailabilityCheckWorker(app.config, Queue(), Queue(), rate_limits)
|
||||
with mock.patch('time.time', return_value=0.0):
|
||||
@ -1026,22 +1025,22 @@ def test_limit_rate_doubles_previous_wait_time(app: Sphinx) -> None:
|
||||
|
||||
|
||||
@pytest.mark.sphinx(confoverrides={'linkcheck_rate_limit_timeout': 90})
|
||||
def test_limit_rate_clips_wait_time_to_max_time(app: Sphinx, warning: StringIO) -> None:
|
||||
def test_limit_rate_clips_wait_time_to_max_time(app: SphinxTestApp) -> None:
|
||||
rate_limits = {"localhost": RateLimit(60.0, 0.0)}
|
||||
worker = HyperlinkAvailabilityCheckWorker(app.config, Queue(), Queue(), rate_limits)
|
||||
with mock.patch('time.time', return_value=0.0):
|
||||
next_check = worker.limit_rate(FakeResponse.url, FakeResponse.headers.get("Retry-After"))
|
||||
assert next_check == 90.0
|
||||
assert warning.getvalue() == ''
|
||||
assert app.warning.getvalue() == ''
|
||||
|
||||
|
||||
@pytest.mark.sphinx(confoverrides={'linkcheck_rate_limit_timeout': 90.0})
|
||||
def test_limit_rate_bails_out_after_waiting_max_time(app: Sphinx, warning: StringIO) -> None:
|
||||
def test_limit_rate_bails_out_after_waiting_max_time(app: SphinxTestApp) -> None:
|
||||
rate_limits = {"localhost": RateLimit(90.0, 0.0)}
|
||||
worker = HyperlinkAvailabilityCheckWorker(app.config, Queue(), Queue(), rate_limits)
|
||||
next_check = worker.limit_rate(FakeResponse.url, FakeResponse.headers.get("Retry-After"))
|
||||
assert next_check is None
|
||||
assert warning.getvalue() == ''
|
||||
assert app.warning.getvalue() == ''
|
||||
|
||||
|
||||
@mock.patch('sphinx.util.requests.requests.Session.get_adapter')
|
||||
@ -1101,7 +1100,7 @@ class ConnectionResetHandler(BaseHTTPRequestHandler):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('linkcheck', testroot='linkcheck-localserver', freshenv=True)
|
||||
def test_get_after_head_raises_connection_error(app: Sphinx) -> None:
|
||||
def test_get_after_head_raises_connection_error(app: SphinxTestApp) -> None:
|
||||
with serve_application(app, ConnectionResetHandler) as address:
|
||||
app.build()
|
||||
content = (app.outdir / 'output.txt').read_text(encoding='utf8')
|
||||
@ -1118,7 +1117,7 @@ def test_get_after_head_raises_connection_error(app: Sphinx) -> None:
|
||||
|
||||
|
||||
@pytest.mark.sphinx('linkcheck', testroot='linkcheck-documents_exclude', freshenv=True)
|
||||
def test_linkcheck_exclude_documents(app: Sphinx) -> None:
|
||||
def test_linkcheck_exclude_documents(app: SphinxTestApp) -> None:
|
||||
with serve_application(app, DefaultsHandler):
|
||||
app.build()
|
||||
|
||||
|
@ -10,7 +10,7 @@ from sphinx.config import Config
|
||||
@pytest.mark.xfail(docutils.__version_info__[:2] > (0, 21),
|
||||
reason='Docutils has removed the reference key in master')
|
||||
@pytest.mark.sphinx('man')
|
||||
def test_all(app, status, warning):
|
||||
def test_all(app):
|
||||
app.build(force_all=True)
|
||||
assert (app.outdir / 'sphinxtests.1').exists()
|
||||
|
||||
@ -35,7 +35,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):
|
||||
def test_man_pages_empty_description(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'title.1').read_text(encoding='utf8')
|
||||
@ -44,7 +44,7 @@ def test_man_pages_empty_description(app, status, warning):
|
||||
|
||||
@pytest.mark.sphinx('man', testroot='basic',
|
||||
confoverrides={'man_make_section_directory': True})
|
||||
def test_man_make_section_directory(app, status, warning):
|
||||
def test_man_make_section_directory(app):
|
||||
app.build()
|
||||
assert (app.outdir / 'man1' / 'projectnamenotset.1').exists()
|
||||
|
||||
@ -52,7 +52,7 @@ def test_man_make_section_directory(app, status, warning):
|
||||
@pytest.mark.xfail(docutils.__version_info__[:2] > (0, 21),
|
||||
reason='Docutils has removed the reference key in master')
|
||||
@pytest.mark.sphinx('man', testroot='directive-code')
|
||||
def test_captioned_code_block(app, status, warning):
|
||||
def test_captioned_code_block(app):
|
||||
app.build(force_all=True)
|
||||
content = (app.outdir / 'projectnamenotset.1').read_text(encoding='utf8')
|
||||
|
||||
@ -102,7 +102,7 @@ def test_default_man_pages():
|
||||
|
||||
|
||||
@pytest.mark.sphinx('man', testroot='markup-rubric')
|
||||
def test_rubric(app, status, warning):
|
||||
def test_rubric(app):
|
||||
app.build()
|
||||
content = (app.outdir / 'projectnamenotset.1').read_text(encoding='utf8')
|
||||
assert 'This is a rubric\n' in content
|
||||
|
@ -15,7 +15,7 @@ from sphinx.writers.texinfo import TexinfoTranslator
|
||||
|
||||
|
||||
@pytest.mark.sphinx('texinfo')
|
||||
def test_texinfo(app, status, warning):
|
||||
def test_texinfo(app):
|
||||
TexinfoTranslator.ignore_missing_images = True
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'sphinxtests.texi').read_text(encoding='utf8')
|
||||
@ -37,7 +37,7 @@ def test_texinfo(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('texinfo', testroot='markup-rubric')
|
||||
def test_texinfo_rubric(app, status, warning):
|
||||
def test_texinfo_rubric(app):
|
||||
app.build()
|
||||
|
||||
output = (app.outdir / 'projectnamenotset.texi').read_text(encoding='utf8')
|
||||
@ -47,7 +47,7 @@ def test_texinfo_rubric(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('texinfo', testroot='markup-citation')
|
||||
def test_texinfo_citation(app, status, warning):
|
||||
def test_texinfo_citation(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
output = (app.outdir / 'projectnamenotset.texi').read_text(encoding='utf8')
|
||||
@ -68,7 +68,7 @@ def test_default_texinfo_documents():
|
||||
|
||||
|
||||
@pytest.mark.sphinx('texinfo')
|
||||
def test_texinfo_escape_id(app, status, warning):
|
||||
def test_texinfo_escape_id(app):
|
||||
settings = Mock(title='',
|
||||
texinfo_dir_entry='',
|
||||
texinfo_elements={})
|
||||
@ -85,7 +85,7 @@ def test_texinfo_escape_id(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('texinfo', testroot='footnotes')
|
||||
def test_texinfo_footnote(app, status, warning):
|
||||
def test_texinfo_footnote(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
output = (app.outdir / 'projectnamenotset.texi').read_text(encoding='utf8')
|
||||
@ -93,7 +93,7 @@ def test_texinfo_footnote(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('texinfo')
|
||||
def test_texinfo_xrefs(app, status, warning):
|
||||
def test_texinfo_xrefs(app):
|
||||
app.build(force_all=True)
|
||||
output = (app.outdir / 'sphinxtests.texi').read_text(encoding='utf8')
|
||||
assert re.search(r'@ref{\w+,,--plugin\.option}', output)
|
||||
@ -107,7 +107,7 @@ def test_texinfo_xrefs(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('texinfo', testroot='root')
|
||||
def test_texinfo_samp_with_variable(app, status, warning):
|
||||
def test_texinfo_samp_with_variable(app):
|
||||
app.build()
|
||||
|
||||
output = (app.outdir / 'sphinxtests.texi').read_text(encoding='utf8')
|
||||
@ -118,7 +118,7 @@ def test_texinfo_samp_with_variable(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('texinfo', testroot='images')
|
||||
def test_copy_images(app, status, warning):
|
||||
def test_copy_images(app):
|
||||
app.build()
|
||||
|
||||
images_dir = Path(app.outdir) / 'projectnamenotset-figures'
|
||||
|
@ -23,7 +23,7 @@ def with_text_app(*args: Any, **kw: Any) -> pytest.MarkDecorator:
|
||||
|
||||
|
||||
@with_text_app()
|
||||
def test_maxwitdh_with_prefix(app, status, warning):
|
||||
def test_maxwitdh_with_prefix(app):
|
||||
app.build()
|
||||
result = (app.outdir / 'maxwidth.txt').read_text(encoding='utf8')
|
||||
|
||||
@ -45,7 +45,7 @@ def test_maxwitdh_with_prefix(app, status, warning):
|
||||
|
||||
|
||||
@with_text_app()
|
||||
def test_lineblock(app, status, warning):
|
||||
def test_lineblock(app):
|
||||
# regression test for #1109: need empty line after line block
|
||||
app.build()
|
||||
result = (app.outdir / 'lineblock.txt').read_text(encoding='utf8')
|
||||
@ -61,7 +61,7 @@ def test_lineblock(app, status, warning):
|
||||
|
||||
|
||||
@with_text_app()
|
||||
def test_nonascii_title_line(app, status, warning):
|
||||
def test_nonascii_title_line(app):
|
||||
app.build()
|
||||
result = (app.outdir / 'nonascii_title.txt').read_text(encoding='utf8')
|
||||
expect_underline = '*********'
|
||||
@ -70,7 +70,7 @@ def test_nonascii_title_line(app, status, warning):
|
||||
|
||||
|
||||
@with_text_app()
|
||||
def test_nonascii_table(app, status, warning):
|
||||
def test_nonascii_table(app):
|
||||
app.build()
|
||||
result = (app.outdir / 'nonascii_table.txt').read_text(encoding='utf8')
|
||||
lines = [line.strip() for line in result.splitlines() if line.strip()]
|
||||
@ -79,7 +79,7 @@ def test_nonascii_table(app, status, warning):
|
||||
|
||||
|
||||
@with_text_app()
|
||||
def test_nonascii_maxwidth(app, status, warning):
|
||||
def test_nonascii_maxwidth(app):
|
||||
app.build()
|
||||
result = (app.outdir / 'nonascii_maxwidth.txt').read_text(encoding='utf8')
|
||||
lines = [line.strip() for line in result.splitlines() if line.strip()]
|
||||
@ -123,7 +123,7 @@ def test_table_cell():
|
||||
|
||||
|
||||
@with_text_app()
|
||||
def test_table_with_empty_cell(app, status, warning):
|
||||
def test_table_with_empty_cell(app):
|
||||
app.build()
|
||||
result = (app.outdir / 'table.txt').read_text(encoding='utf8')
|
||||
lines = [line.strip() for line in result.splitlines() if line.strip()]
|
||||
@ -137,7 +137,7 @@ def test_table_with_empty_cell(app, status, warning):
|
||||
|
||||
|
||||
@with_text_app()
|
||||
def test_table_with_rowspan(app, status, warning):
|
||||
def test_table_with_rowspan(app):
|
||||
app.build()
|
||||
result = (app.outdir / 'table_rowspan.txt').read_text(encoding='utf8')
|
||||
lines = [line.strip() for line in result.splitlines() if line.strip()]
|
||||
@ -151,7 +151,7 @@ def test_table_with_rowspan(app, status, warning):
|
||||
|
||||
|
||||
@with_text_app()
|
||||
def test_table_with_colspan(app, status, warning):
|
||||
def test_table_with_colspan(app):
|
||||
app.build()
|
||||
result = (app.outdir / 'table_colspan.txt').read_text(encoding='utf8')
|
||||
lines = [line.strip() for line in result.splitlines() if line.strip()]
|
||||
@ -165,7 +165,7 @@ def test_table_with_colspan(app, status, warning):
|
||||
|
||||
|
||||
@with_text_app()
|
||||
def test_table_with_colspan_left(app, status, warning):
|
||||
def test_table_with_colspan_left(app):
|
||||
app.build()
|
||||
result = (app.outdir / 'table_colspan_left.txt').read_text(encoding='utf8')
|
||||
lines = [line.strip() for line in result.splitlines() if line.strip()]
|
||||
@ -179,7 +179,7 @@ def test_table_with_colspan_left(app, status, warning):
|
||||
|
||||
|
||||
@with_text_app()
|
||||
def test_table_with_colspan_and_rowspan(app, status, warning):
|
||||
def test_table_with_colspan_and_rowspan(app):
|
||||
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()]
|
||||
@ -194,7 +194,7 @@ def test_table_with_colspan_and_rowspan(app, status, warning):
|
||||
|
||||
|
||||
@with_text_app()
|
||||
def test_list_items_in_admonition(app, status, warning):
|
||||
def test_list_items_in_admonition(app):
|
||||
app.build()
|
||||
result = (app.outdir / 'listitems.txt').read_text(encoding='utf8')
|
||||
lines = [line.rstrip() for line in result.splitlines()]
|
||||
@ -206,7 +206,7 @@ def test_list_items_in_admonition(app, status, warning):
|
||||
|
||||
|
||||
@with_text_app()
|
||||
def test_secnums(app, status, warning):
|
||||
def test_secnums(app):
|
||||
app.build(force_all=True)
|
||||
index = (app.outdir / 'index.txt').read_text(encoding='utf8')
|
||||
lines = index.splitlines()
|
||||
|
@ -52,24 +52,24 @@ def _check_warnings(expected_warnings: str, warning: str) -> None:
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='warnings', freshenv=True)
|
||||
def test_html_warnings(app, warning):
|
||||
def test_html_warnings(app):
|
||||
app.build(force_all=True)
|
||||
warnings_exp = HTML_WARNINGS.format(root=re.escape(app.srcdir.as_posix()))
|
||||
_check_warnings(warnings_exp, warning.getvalue())
|
||||
_check_warnings(warnings_exp, app.warning.getvalue())
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='warnings', freshenv=True)
|
||||
def test_latex_warnings(app, warning):
|
||||
def test_latex_warnings(app):
|
||||
app.build(force_all=True)
|
||||
warnings_exp = LATEX_WARNINGS.format(root=re.escape(app.srcdir.as_posix()))
|
||||
_check_warnings(warnings_exp, warning.getvalue())
|
||||
_check_warnings(warnings_exp, app.warning.getvalue())
|
||||
|
||||
|
||||
@pytest.mark.sphinx('texinfo', testroot='warnings', freshenv=True)
|
||||
def test_texinfo_warnings(app, warning):
|
||||
def test_texinfo_warnings(app):
|
||||
app.build(force_all=True)
|
||||
warnings_exp = TEXINFO_WARNINGS.format(root=re.escape(app.srcdir.as_posix()))
|
||||
_check_warnings(warnings_exp, warning.getvalue())
|
||||
_check_warnings(warnings_exp, app.warning.getvalue())
|
||||
|
||||
|
||||
def test_uncacheable_config_warning(make_app, tmp_path):
|
||||
|
@ -82,7 +82,7 @@ def test_config_opt_deprecated(recwarn):
|
||||
'nonexisting_value': 'True',
|
||||
'latex_elements.maketitle': 'blah blah blah',
|
||||
'modindex_common_prefix': 'path1,path2'})
|
||||
def test_core_config(app, status, warning):
|
||||
def test_core_config(app):
|
||||
cfg = app.config
|
||||
|
||||
# simple values
|
||||
@ -445,8 +445,8 @@ def test_config_eol(logger, tmp_path):
|
||||
@pytest.mark.sphinx(confoverrides={'root_doc': 123,
|
||||
'language': 'foo',
|
||||
'primary_domain': None})
|
||||
def test_builtin_conf(app, status, warning):
|
||||
warnings = warning.getvalue()
|
||||
def test_builtin_conf(app):
|
||||
warnings = app.warning.getvalue()
|
||||
assert 'root_doc' in warnings, (
|
||||
'override on builtin "root_doc" should raise a type warning')
|
||||
assert 'language' not in warnings, (
|
||||
@ -565,10 +565,10 @@ nitpick_warnings = [
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='nitpicky-warnings')
|
||||
def test_nitpick_base(app, status, warning):
|
||||
def test_nitpick_base(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
warning = warning.getvalue().strip().split('\n')
|
||||
warning = app.warning.getvalue().strip().split('\n')
|
||||
for actual, expected in zip(warning, nitpick_warnings, strict=True):
|
||||
assert expected in actual
|
||||
|
||||
@ -581,9 +581,9 @@ def test_nitpick_base(app, status, warning):
|
||||
('js:class', 'prefix.anything.postfix'),
|
||||
},
|
||||
})
|
||||
def test_nitpick_ignore(app, status, warning):
|
||||
def test_nitpick_ignore(app):
|
||||
app.build(force_all=True)
|
||||
assert not len(warning.getvalue().strip())
|
||||
assert not len(app.warning.getvalue().strip())
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='nitpicky-warnings', confoverrides={
|
||||
@ -592,9 +592,9 @@ def test_nitpick_ignore(app, status, warning):
|
||||
(r'.*:class', r'prefix.*'),
|
||||
],
|
||||
})
|
||||
def test_nitpick_ignore_regex1(app, status, warning):
|
||||
def test_nitpick_ignore_regex1(app):
|
||||
app.build(force_all=True)
|
||||
assert not len(warning.getvalue().strip())
|
||||
assert not len(app.warning.getvalue().strip())
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='nitpicky-warnings', confoverrides={
|
||||
@ -603,9 +603,9 @@ def test_nitpick_ignore_regex1(app, status, warning):
|
||||
(r'.*:class', r'.*postfix'),
|
||||
],
|
||||
})
|
||||
def test_nitpick_ignore_regex2(app, status, warning):
|
||||
def test_nitpick_ignore_regex2(app):
|
||||
app.build(force_all=True)
|
||||
assert not len(warning.getvalue().strip())
|
||||
assert not len(app.warning.getvalue().strip())
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='nitpicky-warnings', confoverrides={
|
||||
@ -620,10 +620,10 @@ def test_nitpick_ignore_regex2(app, status, warning):
|
||||
(r'.*', r''),
|
||||
],
|
||||
})
|
||||
def test_nitpick_ignore_regex_fullmatch(app, status, warning):
|
||||
def test_nitpick_ignore_regex_fullmatch(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
warning = warning.getvalue().strip().split('\n')
|
||||
warning = app.warning.getvalue().strip().split('\n')
|
||||
for actual, expected in zip(warning, nitpick_warnings, strict=True):
|
||||
assert expected in actual
|
||||
|
||||
|
@ -105,7 +105,7 @@ def test_LiteralIncludeReader_lines_and_lineno_match1(literal_inc_path):
|
||||
|
||||
|
||||
@pytest.mark.sphinx # init locale for errors
|
||||
def test_LiteralIncludeReader_lines_and_lineno_match2(literal_inc_path, app, status, warning):
|
||||
def test_LiteralIncludeReader_lines_and_lineno_match2(literal_inc_path, app):
|
||||
options = {'lines': '0,3,5', 'lineno-match': True}
|
||||
reader = LiteralIncludeReader(literal_inc_path, options, DUMMY_CONFIG)
|
||||
with pytest.raises(ValueError, match='Cannot use "lineno-match" with a disjoint set of "lines"'):
|
||||
@ -113,7 +113,7 @@ def test_LiteralIncludeReader_lines_and_lineno_match2(literal_inc_path, app, sta
|
||||
|
||||
|
||||
@pytest.mark.sphinx # init locale for errors
|
||||
def test_LiteralIncludeReader_lines_and_lineno_match3(literal_inc_path, app, status, warning):
|
||||
def test_LiteralIncludeReader_lines_and_lineno_match3(literal_inc_path, app):
|
||||
options = {'lines': '100-', 'lineno-match': True}
|
||||
reader = LiteralIncludeReader(literal_inc_path, options, DUMMY_CONFIG)
|
||||
with pytest.raises(ValueError, match="Line spec '100-': no lines pulled from include file"):
|
||||
@ -294,7 +294,7 @@ def test_LiteralIncludeReader_diff(testroot, literal_inc_path):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('xml', testroot='directive-code')
|
||||
def test_code_block(app, status, warning):
|
||||
def test_code_block(app):
|
||||
app.build(filenames=[app.srcdir / 'index.rst'])
|
||||
et = etree_parse(app.outdir / 'index.xml')
|
||||
secs = et.findall('./section/section')
|
||||
@ -310,13 +310,13 @@ def test_code_block(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='directive-code')
|
||||
def test_force_option(app, status, warning):
|
||||
def test_force_option(app):
|
||||
app.build(filenames=[app.srcdir / 'force.rst'])
|
||||
assert 'force.rst' not in warning.getvalue()
|
||||
assert 'force.rst' not in app.warning.getvalue()
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='directive-code')
|
||||
def test_code_block_caption_html(app, status, warning):
|
||||
def test_code_block_caption_html(app):
|
||||
app.build(filenames=[app.srcdir / 'caption.rst'])
|
||||
html = (app.outdir / 'caption.html').read_text(encoding='utf8')
|
||||
caption = ('<div class="code-block-caption">'
|
||||
@ -328,7 +328,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):
|
||||
def test_code_block_caption_latex(app):
|
||||
app.build(force_all=True)
|
||||
latex = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
caption = '\\sphinxSetupCaptionForVerbatim{caption \\sphinxstyleemphasis{test} rb}'
|
||||
@ -341,7 +341,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):
|
||||
def test_code_block_namedlink_latex(app):
|
||||
app.build(force_all=True)
|
||||
latex = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
label1 = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:name-test-rb}}}'
|
||||
@ -358,7 +358,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):
|
||||
def test_code_block_emphasize_latex(app):
|
||||
app.build(filenames=[app.srcdir / 'emphasize.rst'])
|
||||
latex = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8').replace('\r\n', '\n')
|
||||
includes = '\\fvset{hllines={, 5, 6, 13, 14, 15, 24, 25, 26,}}%\n'
|
||||
@ -368,7 +368,7 @@ def test_code_block_emphasize_latex(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('xml', testroot='directive-code')
|
||||
def test_literal_include(app, status, warning):
|
||||
def test_literal_include(app):
|
||||
app.build(filenames=[app.srcdir / 'index.rst'])
|
||||
et = etree_parse(app.outdir / 'index.xml')
|
||||
secs = et.findall('./section/section')
|
||||
@ -380,7 +380,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):
|
||||
def test_literal_include_block_start_with_comment_or_brank(app):
|
||||
app.build(filenames=[app.srcdir / 'python.rst'])
|
||||
et = etree_parse(app.outdir / 'python.xml')
|
||||
secs = et.findall('./section/section')
|
||||
@ -404,7 +404,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):
|
||||
def test_literal_include_linenos(app):
|
||||
app.build(filenames=[app.srcdir / 'linenos.rst'])
|
||||
html = (app.outdir / 'linenos.html').read_text(encoding='utf8')
|
||||
|
||||
@ -422,7 +422,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):
|
||||
def test_literalinclude_file_whole_of_emptyline(app):
|
||||
app.build(force_all=True)
|
||||
latex = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8').replace('\r\n', '\n')
|
||||
includes = (
|
||||
@ -436,7 +436,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):
|
||||
def test_literalinclude_caption_html(app):
|
||||
app.build(force_all=True)
|
||||
html = (app.outdir / 'caption.html').read_text(encoding='utf8')
|
||||
caption = ('<div class="code-block-caption">'
|
||||
@ -448,7 +448,7 @@ def test_literalinclude_caption_html(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='directive-code')
|
||||
def test_literalinclude_caption_latex(app, status, warning):
|
||||
def test_literalinclude_caption_latex(app):
|
||||
app.build(filenames='index')
|
||||
latex = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
caption = '\\sphinxSetupCaptionForVerbatim{caption \\sphinxstylestrong{test} py}'
|
||||
@ -461,7 +461,7 @@ def test_literalinclude_caption_latex(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='directive-code')
|
||||
def test_literalinclude_namedlink_latex(app, status, warning):
|
||||
def test_literalinclude_namedlink_latex(app):
|
||||
app.build(filenames='index')
|
||||
latex = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
label1 = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:name-test-py}}}'
|
||||
@ -478,7 +478,7 @@ def test_literalinclude_namedlink_latex(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('xml', testroot='directive-code')
|
||||
def test_literalinclude_classes(app, status, warning):
|
||||
def test_literalinclude_classes(app):
|
||||
app.build(filenames=[app.srcdir / 'classes.rst'])
|
||||
et = etree_parse(app.outdir / 'classes.xml')
|
||||
secs = et.findall('./section/section')
|
||||
@ -495,7 +495,7 @@ def test_literalinclude_classes(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('xml', testroot='directive-code')
|
||||
def test_literalinclude_pydecorators(app, status, warning):
|
||||
def test_literalinclude_pydecorators(app):
|
||||
app.build(filenames=[app.srcdir / 'py-decorators.rst'])
|
||||
et = etree_parse(app.outdir / 'py-decorators.xml')
|
||||
secs = et.findall('./section/section')
|
||||
@ -536,7 +536,7 @@ def test_literalinclude_pydecorators(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='directive-code')
|
||||
def test_code_block_highlighted(app, status, warning):
|
||||
def test_code_block_highlighted(app):
|
||||
app.build(filenames=[app.srcdir / 'highlight.rst'])
|
||||
doctree = app.env.get_doctree('highlight')
|
||||
codeblocks = list(doctree.findall(nodes.literal_block))
|
||||
@ -548,7 +548,7 @@ def test_code_block_highlighted(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='directive-code')
|
||||
def test_linenothreshold(app, status, warning):
|
||||
def test_linenothreshold(app):
|
||||
app.build(filenames=[app.srcdir / 'linenothreshold.rst'])
|
||||
html = (app.outdir / 'linenothreshold.html').read_text(encoding='utf8')
|
||||
|
||||
@ -569,7 +569,7 @@ def test_linenothreshold(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='directive-code')
|
||||
def test_code_block_dedent(app, status, warning):
|
||||
def test_code_block_dedent(app):
|
||||
app.build(filenames=[app.srcdir / 'dedent.rst'])
|
||||
doctree = app.env.get_doctree('dedent')
|
||||
codeblocks = list(doctree.findall(nodes.literal_block))
|
||||
|
@ -7,7 +7,7 @@ from docutils import nodes
|
||||
|
||||
|
||||
@pytest.mark.sphinx('text', testroot='directive-only')
|
||||
def test_sectioning(app, status, warning):
|
||||
def test_sectioning(app):
|
||||
|
||||
def getsects(section):
|
||||
if not isinstance(section, nodes.section):
|
||||
|
@ -3,7 +3,7 @@ import pytest
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root',
|
||||
confoverrides={'option_emphasise_placeholders': True})
|
||||
def test_option_emphasise_placeholders(app, status, warning):
|
||||
def test_option_emphasise_placeholders(app):
|
||||
app.build()
|
||||
content = (app.outdir / 'objects.html').read_text(encoding='utf8')
|
||||
assert '<em><span class="pre">TYPE</span></em>' in content
|
||||
@ -17,7 +17,7 @@ def test_option_emphasise_placeholders(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root')
|
||||
def test_option_emphasise_placeholders_default(app, status, warning):
|
||||
def test_option_emphasise_placeholders_default(app):
|
||||
app.build()
|
||||
content = (app.outdir / 'objects.html').read_text(encoding='utf8')
|
||||
assert '<span class="pre">={TYPE}</span>' in content
|
||||
@ -29,7 +29,7 @@ def test_option_emphasise_placeholders_default(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root')
|
||||
def test_option_reference_with_value(app, status, warning):
|
||||
def test_option_reference_with_value(app):
|
||||
app.build()
|
||||
content = (app.outdir / 'objects.html').read_text(encoding='utf-8')
|
||||
assert ('<span class="pre">-mapi</span></span><span class="sig-prename descclassname">'
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
import itertools
|
||||
import zlib
|
||||
from io import StringIO
|
||||
from xml.etree import ElementTree
|
||||
|
||||
import pytest
|
||||
@ -616,15 +617,15 @@ def test_extra_keywords():
|
||||
# raise DefinitionError
|
||||
|
||||
|
||||
def split_warnigns(warning):
|
||||
def split_warnings(warning: StringIO):
|
||||
ws = warning.getvalue().split("\n")
|
||||
assert len(ws) >= 1
|
||||
assert ws[-1] == ""
|
||||
return ws[:-1]
|
||||
|
||||
|
||||
def filter_warnings(warning, file):
|
||||
lines = split_warnigns(warning)
|
||||
def filter_warnings(warning: StringIO, file):
|
||||
lines = split_warnings(warning)
|
||||
res = [l for l in lines if "domain-c" in l and f"{file}.rst" in l and
|
||||
"WARNING: document isn't included in any toctree" not in l]
|
||||
print(f"Filtered warnings for file '{file}':")
|
||||
@ -653,16 +654,16 @@ def extract_role_links(app, filename):
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='domain-c', confoverrides={'nitpicky': True})
|
||||
def test_domain_c_build(app, status, warning):
|
||||
def test_domain_c_build(app):
|
||||
app.build(force_all=True)
|
||||
ws = filter_warnings(warning, "index")
|
||||
ws = filter_warnings(app.warning, "index")
|
||||
assert len(ws) == 0
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='domain-c', confoverrides={'nitpicky': True})
|
||||
def test_domain_c_build_namespace(app, status, warning):
|
||||
def test_domain_c_build_namespace(app):
|
||||
app.build(force_all=True)
|
||||
ws = filter_warnings(warning, "namespace")
|
||||
ws = filter_warnings(app.warning, "namespace")
|
||||
assert len(ws) == 0
|
||||
t = (app.outdir / "namespace.html").read_text(encoding='utf8')
|
||||
for id_ in ('NS.NSVar', 'NULLVar', 'ZeroVar', 'NS2.NS3.NS2NS3Var', 'PopVar'):
|
||||
@ -670,16 +671,16 @@ 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):
|
||||
def test_domain_c_build_anon_dup_decl(app):
|
||||
app.build(force_all=True)
|
||||
ws = filter_warnings(warning, "anon-dup-decl")
|
||||
ws = filter_warnings(app.warning, "anon-dup-decl")
|
||||
assert len(ws) == 2
|
||||
assert "WARNING: c:identifier reference target not found: @a" in ws[0]
|
||||
assert "WARNING: c:identifier reference target not found: @b" in ws[1]
|
||||
|
||||
|
||||
@pytest.mark.sphinx(confoverrides={'nitpicky': True})
|
||||
def test_domain_c_build_semicolon(app, warning):
|
||||
def test_domain_c_build_semicolon(app):
|
||||
text = """
|
||||
.. c:member:: int member;
|
||||
.. c:var:: int var;
|
||||
@ -693,15 +694,15 @@ def test_domain_c_build_semicolon(app, warning):
|
||||
.. c:type:: int TypeDef;
|
||||
"""
|
||||
restructuredtext.parse(app, text)
|
||||
ws = split_warnigns(warning)
|
||||
ws = split_warnings(app.warning)
|
||||
assert len(ws) == 0
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='domain-c', confoverrides={'nitpicky': True})
|
||||
def test_domain_c_build_function_param_target(app, warning):
|
||||
def test_domain_c_build_function_param_target(app):
|
||||
# the anchor for function parameters should be the function
|
||||
app.build(force_all=True)
|
||||
ws = filter_warnings(warning, "function_param_target")
|
||||
ws = filter_warnings(app.warning, "function_param_target")
|
||||
assert len(ws) == 0
|
||||
entries = extract_role_links(app, "function_param_target.html")
|
||||
assert entries == [
|
||||
@ -711,16 +712,16 @@ 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):
|
||||
def test_domain_c_build_ns_lookup(app):
|
||||
app.build(force_all=True)
|
||||
ws = filter_warnings(warning, "ns_lookup")
|
||||
ws = filter_warnings(app.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):
|
||||
def test_domain_c_build_field_role(app):
|
||||
app.build(force_all=True)
|
||||
ws = filter_warnings(warning, "field-role")
|
||||
ws = filter_warnings(app.warning, "field-role")
|
||||
assert len(ws) == 0
|
||||
|
||||
|
||||
@ -733,7 +734,7 @@ def _get_obj(app, queryName):
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='domain-c-intersphinx', confoverrides={'nitpicky': True})
|
||||
def test_domain_c_build_intersphinx(tmp_path, app, status, warning):
|
||||
def test_domain_c_build_intersphinx(tmp_path, app):
|
||||
# a splitting of test_ids_vs_tags0 into the primary directives in a remote project,
|
||||
# and then the references in the test project
|
||||
origSource = """\
|
||||
@ -754,7 +755,7 @@ def test_domain_c_build_intersphinx(tmp_path, app, status, warning):
|
||||
inv_file.write_bytes(b'''\
|
||||
# Sphinx inventory version 2
|
||||
# Project: C Intersphinx Test
|
||||
# Version:
|
||||
# Version:
|
||||
# The remainder of this file is compressed using zlib.
|
||||
''' + zlib.compress(b'''\
|
||||
_enum c:enum 1 index.html#c.$ -
|
||||
@ -779,7 +780,7 @@ _var c:member 1 index.html#c.$ -
|
||||
load_mappings(app)
|
||||
|
||||
app.build(force_all=True)
|
||||
ws = filter_warnings(warning, "index")
|
||||
ws = filter_warnings(app.warning, "index")
|
||||
assert len(ws) == 0
|
||||
|
||||
|
||||
@ -1038,7 +1039,7 @@ def test_c_maximum_signature_line_length_overrides_global(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='domain-c-c_maximum_signature_line_length')
|
||||
def test_domain_c_c_maximum_signature_line_length_in_html(app, status, warning):
|
||||
def test_domain_c_c_maximum_signature_line_length_in_html(app):
|
||||
app.build()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf-8')
|
||||
expected = """\
|
||||
@ -1062,7 +1063,7 @@ def test_domain_c_c_maximum_signature_line_length_in_html(app, status, warning):
|
||||
@pytest.mark.sphinx(
|
||||
'text', testroot='domain-c-c_maximum_signature_line_length',
|
||||
)
|
||||
def test_domain_c_c_maximum_signature_line_length_in_text(app, status, warning):
|
||||
def test_domain_c_c_maximum_signature_line_length_in_text(app):
|
||||
app.build()
|
||||
content = (app.outdir / 'index.txt').read_text(encoding='utf8')
|
||||
param_line_fmt = STDINDENT * " " + "{}\n"
|
||||
|
@ -3,6 +3,7 @@
|
||||
import itertools
|
||||
import re
|
||||
import zlib
|
||||
from io import StringIO
|
||||
|
||||
import pytest
|
||||
|
||||
@ -1102,7 +1103,7 @@ def test_domain_cpp_template_parameters_is_pack(param: str, is_pack: bool):
|
||||
# raise DefinitionError
|
||||
|
||||
|
||||
def filter_warnings(warning, file):
|
||||
def filter_warnings(warning: StringIO, file):
|
||||
lines = warning.getvalue().split("\n")
|
||||
res = [l for l in lines if "domain-cpp" in l and f"{file}.rst" in l and
|
||||
"WARNING: document isn't included in any toctree" not in l]
|
||||
@ -1113,63 +1114,63 @@ 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):
|
||||
def test_domain_cpp_build_multi_decl_lookup(app):
|
||||
app.build(force_all=True)
|
||||
ws = filter_warnings(warning, "lookup-key-overload")
|
||||
ws = filter_warnings(app.warning, "lookup-key-overload")
|
||||
assert len(ws) == 0
|
||||
|
||||
ws = filter_warnings(warning, "multi-decl-lookup")
|
||||
ws = filter_warnings(app.warning, "multi-decl-lookup")
|
||||
assert len(ws) == 0
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='domain-cpp', confoverrides={'nitpicky': True})
|
||||
def test_domain_cpp_build_warn_template_param_qualified_name(app, status, warning):
|
||||
def test_domain_cpp_build_warn_template_param_qualified_name(app):
|
||||
app.build(force_all=True)
|
||||
ws = filter_warnings(warning, "warn-template-param-qualified-name")
|
||||
ws = filter_warnings(app.warning, "warn-template-param-qualified-name")
|
||||
assert len(ws) == 2
|
||||
assert "WARNING: cpp:type reference target not found: T::typeWarn" in ws[0]
|
||||
assert "WARNING: cpp:type reference target not found: T::U::typeWarn" in ws[1]
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='domain-cpp', confoverrides={'nitpicky': True})
|
||||
def test_domain_cpp_build_backslash_ok_true(app, status, warning):
|
||||
def test_domain_cpp_build_backslash_ok_true(app):
|
||||
app.build(force_all=True)
|
||||
ws = filter_warnings(warning, "backslash")
|
||||
ws = filter_warnings(app.warning, "backslash")
|
||||
assert len(ws) == 0
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='domain-cpp', confoverrides={'nitpicky': True})
|
||||
def test_domain_cpp_build_semicolon(app, status, warning):
|
||||
def test_domain_cpp_build_semicolon(app):
|
||||
app.build(force_all=True)
|
||||
ws = filter_warnings(warning, "semicolon")
|
||||
ws = filter_warnings(app.warning, "semicolon")
|
||||
assert len(ws) == 0
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='domain-cpp',
|
||||
confoverrides={'nitpicky': True, 'strip_signature_backslash': True})
|
||||
def test_domain_cpp_build_backslash_ok_false(app, status, warning):
|
||||
def test_domain_cpp_build_backslash_ok_false(app):
|
||||
app.build(force_all=True)
|
||||
ws = filter_warnings(warning, "backslash")
|
||||
ws = filter_warnings(app.warning, "backslash")
|
||||
assert len(ws) == 1
|
||||
assert "WARNING: Parsing of expression failed. Using fallback parser." in ws[0]
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='domain-cpp', confoverrides={'nitpicky': True})
|
||||
def test_domain_cpp_build_anon_dup_decl(app, status, warning):
|
||||
def test_domain_cpp_build_anon_dup_decl(app):
|
||||
app.build(force_all=True)
|
||||
ws = filter_warnings(warning, "anon-dup-decl")
|
||||
ws = filter_warnings(app.warning, "anon-dup-decl")
|
||||
assert len(ws) == 2
|
||||
assert "WARNING: cpp:identifier reference target not found: @a" in ws[0]
|
||||
assert "WARNING: cpp:identifier reference target not found: @b" in ws[1]
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='domain-cpp')
|
||||
def test_domain_cpp_build_misuse_of_roles(app, status, warning):
|
||||
def test_domain_cpp_build_misuse_of_roles(app):
|
||||
app.build(force_all=True)
|
||||
ws = filter_warnings(warning, "roles-targets-ok")
|
||||
ws = filter_warnings(app.warning, "roles-targets-ok")
|
||||
assert len(ws) == 0
|
||||
|
||||
ws = filter_warnings(warning, "roles-targets-warn")
|
||||
ws = filter_warnings(app.warning, "roles-targets-warn")
|
||||
# the roles that should be able to generate warnings:
|
||||
allRoles = ['class', 'struct', 'union', 'func', 'member', 'var', 'type', 'concept', 'enum', 'enumerator']
|
||||
ok = [ # targetType, okRoles
|
||||
@ -1212,7 +1213,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):
|
||||
def test_domain_cpp_build_with_add_function_parentheses_is_True(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
rolePatterns = [
|
||||
@ -1251,7 +1252,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):
|
||||
def test_domain_cpp_build_with_add_function_parentheses_is_False(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
rolePatterns = [
|
||||
@ -1290,7 +1291,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):
|
||||
def test_domain_cpp_build_xref_consistency(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
test = 'xref_consistency.html'
|
||||
@ -1354,16 +1355,16 @@ not found in `{test}`
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='domain-cpp', confoverrides={'nitpicky': True})
|
||||
def test_domain_cpp_build_field_role(app, status, warning):
|
||||
def test_domain_cpp_build_field_role(app):
|
||||
app.build(force_all=True)
|
||||
ws = filter_warnings(warning, "field-role")
|
||||
ws = filter_warnings(app.warning, "field-role")
|
||||
assert len(ws) == 0
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='domain-cpp', confoverrides={'nitpicky': True})
|
||||
def test_domain_cpp_build_operator_lookup(app, status, warning):
|
||||
def test_domain_cpp_build_operator_lookup(app):
|
||||
app.builder.build_all()
|
||||
ws = filter_warnings(warning, "operator-lookup")
|
||||
ws = filter_warnings(app.warning, "operator-lookup")
|
||||
assert len(ws) == 5
|
||||
# TODO: the first one should not happen
|
||||
assert ":10: WARNING: cpp:identifier reference target not found: _lit" in ws[0]
|
||||
@ -1374,7 +1375,7 @@ def test_domain_cpp_build_operator_lookup(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='domain-cpp-intersphinx', confoverrides={'nitpicky': True})
|
||||
def test_domain_cpp_build_intersphinx(tmp_path, app, status, warning):
|
||||
def test_domain_cpp_build_intersphinx(tmp_path, app):
|
||||
origSource = """\
|
||||
.. cpp:class:: _class
|
||||
.. cpp:struct:: _struct
|
||||
@ -1400,7 +1401,7 @@ def test_domain_cpp_build_intersphinx(tmp_path, app, status, warning):
|
||||
inv_file.write_bytes(b'''\
|
||||
# Sphinx inventory version 2
|
||||
# Project: C Intersphinx Test
|
||||
# Version:
|
||||
# Version:
|
||||
# The remainder of this file is compressed using zlib.
|
||||
''' + zlib.compress(b'''\
|
||||
_class cpp:class 1 index.html#_CPPv46$ -
|
||||
@ -1432,7 +1433,7 @@ _var cpp:member 1 index.html#_CPPv44$ -
|
||||
load_mappings(app)
|
||||
|
||||
app.build(force_all=True)
|
||||
ws = filter_warnings(warning, "index")
|
||||
ws = filter_warnings(app.warning, "index")
|
||||
assert len(ws) == 0
|
||||
|
||||
|
||||
@ -1446,13 +1447,13 @@ def test_domain_cpp_parse_no_index_entry(app):
|
||||
assert_node(doctree[2], addnodes.index, entries=[])
|
||||
|
||||
|
||||
def test_domain_cpp_parse_mix_decl_duplicate(app, warning):
|
||||
def test_domain_cpp_parse_mix_decl_duplicate(app):
|
||||
# Issue 8270
|
||||
text = (".. cpp:struct:: A\n"
|
||||
".. cpp:function:: void A()\n"
|
||||
".. cpp:struct:: A\n")
|
||||
restructuredtext.parse(app, text)
|
||||
ws = warning.getvalue().split("\n")
|
||||
ws = app.warning.getvalue().split("\n")
|
||||
assert len(ws) == 5
|
||||
assert "index.rst:2: WARNING: Duplicate C++ declaration, also defined at index:1." in ws[0]
|
||||
assert "Declaration is '.. cpp:function:: void A()'." in ws[1]
|
||||
@ -1719,7 +1720,7 @@ def test_cpp_maximum_signature_line_length_overrides_global(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='domain-cpp-cpp_maximum_signature_line_length')
|
||||
def test_domain_cpp_cpp_maximum_signature_line_length_in_html(app, status, warning):
|
||||
def test_domain_cpp_cpp_maximum_signature_line_length_in_html(app):
|
||||
app.build()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf-8')
|
||||
expected = """\
|
||||
@ -1741,7 +1742,7 @@ def test_domain_cpp_cpp_maximum_signature_line_length_in_html(app, status, warni
|
||||
@pytest.mark.sphinx(
|
||||
'text', testroot='domain-cpp-cpp_maximum_signature_line_length',
|
||||
)
|
||||
def test_domain_cpp_cpp_maximum_signature_line_length_in_text(app, status, warning):
|
||||
def test_domain_cpp_cpp_maximum_signature_line_length_in_text(app):
|
||||
app.build()
|
||||
content = (app.outdir / 'index.txt').read_text(encoding='utf8')
|
||||
param_line_fmt = STDINDENT * " " + "{}\n"
|
||||
|
@ -26,7 +26,7 @@ from sphinx.writers.text import STDINDENT
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='domain-js')
|
||||
def test_domain_js_xrefs(app, status, warning):
|
||||
def test_domain_js_xrefs(app):
|
||||
"""Domain objects have correct prefixes when looking up xrefs"""
|
||||
app.build(force_all=True)
|
||||
|
||||
@ -82,7 +82,7 @@ def test_domain_js_xrefs(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='domain-js')
|
||||
def test_domain_js_objects(app, status, warning):
|
||||
def test_domain_js_objects(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
modules = app.env.domains['js'].data['modules']
|
||||
@ -112,7 +112,7 @@ def test_domain_js_objects(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='domain-js')
|
||||
def test_domain_js_find_obj(app, status, warning):
|
||||
def test_domain_js_find_obj(app):
|
||||
|
||||
def find_obj(mod_name, prefix, obj_name, obj_type, searchmode=0):
|
||||
return app.env.domains['js'].find_obj(
|
||||
@ -410,7 +410,7 @@ def test_javascript_maximum_signature_line_length_overrides_global(app):
|
||||
@pytest.mark.sphinx(
|
||||
'html', testroot='domain-js-javascript_maximum_signature_line_length',
|
||||
)
|
||||
def test_domain_js_javascript_maximum_signature_line_length_in_html(app, status, warning):
|
||||
def test_domain_js_javascript_maximum_signature_line_length_in_html(app):
|
||||
app.build()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
expected_parameter_list_hello = """\
|
||||
@ -472,7 +472,7 @@ def test_domain_js_javascript_maximum_signature_line_length_in_html(app, status,
|
||||
@pytest.mark.sphinx(
|
||||
'text', testroot='domain-js-javascript_maximum_signature_line_length',
|
||||
)
|
||||
def test_domain_js_javascript_maximum_signature_line_length_in_text(app, status, warning):
|
||||
def test_domain_js_javascript_maximum_signature_line_length_in_text(app):
|
||||
app.build()
|
||||
content = (app.outdir / 'index.txt').read_text(encoding='utf8')
|
||||
param_line_fmt = STDINDENT * " " + "{}\n"
|
||||
|
@ -70,7 +70,7 @@ def test_function_signatures():
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='domain-py')
|
||||
def test_domain_py_xrefs(app, status, warning):
|
||||
def test_domain_py_xrefs(app):
|
||||
"""Domain objects have correct prefixes when looking up xrefs"""
|
||||
app.build(force_all=True)
|
||||
|
||||
@ -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):
|
||||
def test_domain_py_xrefs_abbreviations(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'abbr.html').read_text(encoding='utf8')
|
||||
@ -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):
|
||||
def test_domain_py_objects(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
modules = app.env.domains['py'].data['modules']
|
||||
@ -210,7 +210,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):
|
||||
def test_resolve_xref_for_properties(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'module.html').read_text(encoding='utf8')
|
||||
@ -229,7 +229,7 @@ def test_resolve_xref_for_properties(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='domain-py')
|
||||
def test_domain_py_find_obj(app, status, warning):
|
||||
def test_domain_py_find_obj(app):
|
||||
|
||||
def find_obj(modname, prefix, obj_name, obj_type, searchmode=0):
|
||||
return app.env.domains['py'].find_obj(
|
||||
@ -513,7 +513,7 @@ def test_no_index_entry(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='domain-py-python_use_unqualified_type_names')
|
||||
def test_python_python_use_unqualified_type_names(app, status, warning):
|
||||
def test_python_python_use_unqualified_type_names(app):
|
||||
app.build()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert ('<span class="n"><a class="reference internal" href="#foo.Name" title="foo.Name">'
|
||||
@ -526,7 +526,7 @@ def test_python_python_use_unqualified_type_names(app, status, warning):
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='domain-py-python_use_unqualified_type_names',
|
||||
confoverrides={'python_use_unqualified_type_names': False})
|
||||
def test_python_python_use_unqualified_type_names_disabled(app, status, warning):
|
||||
def test_python_python_use_unqualified_type_names_disabled(app):
|
||||
app.build()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert ('<span class="n"><a class="reference internal" href="#foo.Name" title="foo.Name">'
|
||||
@ -538,11 +538,11 @@ def test_python_python_use_unqualified_type_names_disabled(app, status, warning)
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='domain-py-xref-warning')
|
||||
def test_warn_missing_reference(app, status, warning):
|
||||
def test_warn_missing_reference(app):
|
||||
app.build()
|
||||
assert "index.rst:6: WARNING: undefined label: 'no-label'" in warning.getvalue()
|
||||
assert "index.rst:6: WARNING: undefined label: 'no-label'" in app.warning.getvalue()
|
||||
assert ("index.rst:6: WARNING: Failed to create a cross reference. "
|
||||
"A title or caption not found: 'existing-label'") in warning.getvalue()
|
||||
"A title or caption not found: 'existing-label'") in app.warning.getvalue()
|
||||
|
||||
|
||||
@pytest.mark.sphinx(confoverrides={'nitpicky': True})
|
||||
@ -588,7 +588,7 @@ def test_python_maximum_signature_line_length_overrides_global(app):
|
||||
@pytest.mark.sphinx(
|
||||
'html', testroot='domain-py-python_maximum_signature_line_length',
|
||||
)
|
||||
def test_domain_py_python_maximum_signature_line_length_in_html(app, status, warning):
|
||||
def test_domain_py_python_maximum_signature_line_length_in_html(app):
|
||||
app.build()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
expected_parameter_list_hello = """\
|
||||
@ -657,7 +657,7 @@ def test_domain_py_python_maximum_signature_line_length_in_html(app, status, war
|
||||
@pytest.mark.sphinx(
|
||||
'text', testroot='domain-py-python_maximum_signature_line_length',
|
||||
)
|
||||
def test_domain_py_python_maximum_signature_line_length_in_text(app, status, warning):
|
||||
def test_domain_py_python_maximum_signature_line_length_in_text(app):
|
||||
app.build()
|
||||
content = (app.outdir / 'index.txt').read_text(encoding='utf8')
|
||||
param_line_fmt = STDINDENT * " " + "{}\n"
|
||||
|
@ -19,14 +19,14 @@ from sphinx.testing.util import assert_node
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='domain-py', freshenv=True)
|
||||
def test_domain_py_canonical(app, status, warning):
|
||||
def test_domain_py_canonical(app):
|
||||
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">'
|
||||
'<code class="xref py py-class docutils literal notranslate">'
|
||||
'<span class="pre">Foo</span></code></a>' in content)
|
||||
assert warning.getvalue() == ''
|
||||
assert app.warning.getvalue() == ''
|
||||
|
||||
|
||||
def test_canonical(app):
|
||||
@ -44,34 +44,34 @@ def test_canonical(app):
|
||||
assert domain.objects['_io.StringIO'] == ('index', 'io.StringIO', 'class', True)
|
||||
|
||||
|
||||
def test_canonical_definition_overrides(app, warning):
|
||||
def test_canonical_definition_overrides(app):
|
||||
text = (".. py:class:: io.StringIO\n"
|
||||
" :canonical: _io.StringIO\n"
|
||||
".. py:class:: _io.StringIO\n")
|
||||
restructuredtext.parse(app, text)
|
||||
assert warning.getvalue() == ""
|
||||
assert app.warning.getvalue() == ""
|
||||
|
||||
domain = app.env.get_domain('py')
|
||||
assert domain.objects['_io.StringIO'] == ('index', 'id0', 'class', False)
|
||||
|
||||
|
||||
def test_canonical_definition_skip(app, warning):
|
||||
def test_canonical_definition_skip(app):
|
||||
text = (".. py:class:: _io.StringIO\n"
|
||||
".. py:class:: io.StringIO\n"
|
||||
" :canonical: _io.StringIO\n")
|
||||
|
||||
restructuredtext.parse(app, text)
|
||||
assert warning.getvalue() == ""
|
||||
assert app.warning.getvalue() == ""
|
||||
|
||||
domain = app.env.get_domain('py')
|
||||
assert domain.objects['_io.StringIO'] == ('index', 'io.StringIO', 'class', False)
|
||||
|
||||
|
||||
def test_canonical_duplicated(app, warning):
|
||||
def test_canonical_duplicated(app):
|
||||
text = (".. py:class:: mypackage.StringIO\n"
|
||||
" :canonical: _io.StringIO\n"
|
||||
".. py:class:: io.StringIO\n"
|
||||
" :canonical: _io.StringIO\n")
|
||||
|
||||
restructuredtext.parse(app, text)
|
||||
assert warning.getvalue() != ""
|
||||
assert app.warning.getvalue() != ""
|
||||
|
@ -415,7 +415,7 @@ def test_py_type_alias(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='domain-py', freshenv=True)
|
||||
def test_domain_py_type_alias(app, status, warning):
|
||||
def test_domain_py_type_alias(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'type_alias.html').read_text(encoding='utf8')
|
||||
@ -430,7 +430,7 @@ def test_domain_py_type_alias(app, status, warning):
|
||||
'<a class="reference internal" href="#module_two.SomeClass" title="module_two.SomeClass">'
|
||||
'<span class="pre">module_two.SomeClass</span></a>'
|
||||
'<span class="p"><span class="pre">]</span></span></em>' in content)
|
||||
assert warning.getvalue() == ''
|
||||
assert app.warning.getvalue() == ''
|
||||
|
||||
|
||||
def test_pydecorator_signature(app):
|
||||
|
@ -178,7 +178,7 @@ def test_glossary(app):
|
||||
assert_node(refnode, nodes.reference, refid="term-TERM2")
|
||||
|
||||
|
||||
def test_glossary_warning(app, status, warning):
|
||||
def test_glossary_warning(app):
|
||||
# empty line between terms
|
||||
text = (".. glossary::\n"
|
||||
"\n"
|
||||
@ -187,7 +187,7 @@ def test_glossary_warning(app, status, warning):
|
||||
" term2\n")
|
||||
restructuredtext.parse(app, text, "case1")
|
||||
assert ("case1.rst:4: WARNING: glossary terms must not be separated by empty lines"
|
||||
in warning.getvalue())
|
||||
in app.warning.getvalue())
|
||||
|
||||
# glossary starts with indented item
|
||||
text = (".. glossary::\n"
|
||||
@ -196,7 +196,7 @@ def test_glossary_warning(app, status, warning):
|
||||
" term\n")
|
||||
restructuredtext.parse(app, text, "case2")
|
||||
assert ("case2.rst:3: WARNING: glossary term must be preceded by empty line"
|
||||
in warning.getvalue())
|
||||
in app.warning.getvalue())
|
||||
|
||||
# empty line between terms
|
||||
text = (".. glossary::\n"
|
||||
@ -206,7 +206,7 @@ def test_glossary_warning(app, status, warning):
|
||||
" term2\n")
|
||||
restructuredtext.parse(app, text, "case3")
|
||||
assert ("case3.rst:4: WARNING: glossary term must be preceded by empty line"
|
||||
in warning.getvalue())
|
||||
in app.warning.getvalue())
|
||||
|
||||
# duplicated terms
|
||||
text = (".. glossary::\n"
|
||||
@ -215,7 +215,7 @@ def test_glossary_warning(app, status, warning):
|
||||
" term-case4\n")
|
||||
restructuredtext.parse(app, text, "case4")
|
||||
assert ("case4.rst:3: WARNING: duplicate term description of term-case4, "
|
||||
"other instance in case4" in warning.getvalue())
|
||||
"other instance in case4" in app.warning.getvalue())
|
||||
|
||||
|
||||
def test_glossary_comment(app):
|
||||
@ -366,10 +366,10 @@ def test_multiple_cmdoptions(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='productionlist')
|
||||
def test_productionlist(app, status, warning):
|
||||
def test_productionlist(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
warnings = warning.getvalue().split("\n")
|
||||
warnings = app.warning.getvalue().split("\n")
|
||||
assert len(warnings) == 2
|
||||
assert warnings[-1] == ''
|
||||
assert "Dup2.rst:4: WARNING: duplicate token description of Dup, other instance in Dup1" in warnings[0]
|
||||
|
@ -435,16 +435,16 @@ def _assert_getter_works(app, directive, objtype, name, attrs=(), **kw):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_py_module(app, warning):
|
||||
def test_py_module(app):
|
||||
# without py:module
|
||||
actual = do_autodoc(app, 'method', 'Class.meth')
|
||||
assert list(actual) == []
|
||||
assert ("don't know which module to import for autodocumenting 'Class.meth'"
|
||||
in warning.getvalue())
|
||||
in app.warning.getvalue())
|
||||
|
||||
# with py:module
|
||||
app.env.ref_context['py:module'] = 'target'
|
||||
warning.truncate(0)
|
||||
app.warning.truncate(0)
|
||||
|
||||
actual = do_autodoc(app, 'method', 'Class.meth')
|
||||
assert list(actual) == [
|
||||
@ -456,7 +456,7 @@ def test_py_module(app, warning):
|
||||
'',
|
||||
]
|
||||
assert ("don't know which module to import for autodocumenting 'Class.meth'"
|
||||
not in warning.getvalue())
|
||||
not in app.warning.getvalue())
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
@ -496,23 +496,23 @@ def test_autodoc_exception(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autodoc_warnings(app, warning):
|
||||
def test_autodoc_warnings(app):
|
||||
app.env.temp_data['docname'] = 'dummy'
|
||||
|
||||
# can't import module
|
||||
do_autodoc(app, 'module', 'unknown')
|
||||
assert "failed to import module 'unknown'" in warning.getvalue()
|
||||
assert "failed to import module 'unknown'" in app.warning.getvalue()
|
||||
|
||||
# missing function
|
||||
do_autodoc(app, 'function', 'unknown')
|
||||
assert "import for autodocumenting 'unknown'" in warning.getvalue()
|
||||
assert "import for autodocumenting 'unknown'" in app.warning.getvalue()
|
||||
|
||||
do_autodoc(app, 'function', 'target.unknown')
|
||||
assert "failed to import function 'unknown' from module 'target'" in warning.getvalue()
|
||||
assert "failed to import function 'unknown' from module 'target'" in app.warning.getvalue()
|
||||
|
||||
# missing method
|
||||
do_autodoc(app, 'method', 'target.Class.unknown')
|
||||
assert "failed to import method 'Class.unknown' from module 'target'" in warning.getvalue()
|
||||
assert "failed to import method 'Class.unknown' from module 'target'" in app.warning.getvalue()
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
@ -2705,7 +2705,7 @@ def test_pyclass_for_ClassLevelDocumenter(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='ext-autodoc')
|
||||
def test_autodoc(app, status, warning):
|
||||
def test_autodoc(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
content = app.env.get_doctree('index')
|
||||
@ -2721,7 +2721,7 @@ def test_autodoc(app, status, warning):
|
||||
my_name
|
||||
|
||||
alias of Foo"""
|
||||
assert warning.getvalue() == ''
|
||||
assert app.warning.getvalue() == ''
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
|
@ -608,14 +608,14 @@ def test_autoclass_content_and_docstring_signature_both(app):
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
@pytest.mark.usefixtures("rollback_sysmodules")
|
||||
def test_mocked_module_imports(app, warning):
|
||||
def test_mocked_module_imports(app):
|
||||
sys.modules.pop('target', None) # unload target module to clear the module cache
|
||||
|
||||
# no autodoc_mock_imports
|
||||
options = {"members": 'TestAutodoc,decoratedFunction,func,Alias'}
|
||||
actual = do_autodoc(app, 'module', 'target.need_mocks', options)
|
||||
assert list(actual) == []
|
||||
assert "autodoc: failed to import module 'need_mocks'" in warning.getvalue()
|
||||
assert "autodoc: failed to import module 'need_mocks'" in app.warning.getvalue()
|
||||
|
||||
# with autodoc_mock_imports
|
||||
app.config.autodoc_mock_imports = [
|
||||
@ -626,7 +626,7 @@ def test_mocked_module_imports(app, warning):
|
||||
'sphinx.missing_module4',
|
||||
]
|
||||
|
||||
warning.truncate(0)
|
||||
app.warning.truncate(0)
|
||||
actual = do_autodoc(app, 'module', 'target.need_mocks', options)
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -669,7 +669,7 @@ def test_mocked_module_imports(app, warning):
|
||||
' a function takes mocked object as an argument',
|
||||
'',
|
||||
]
|
||||
assert warning.getvalue() == ''
|
||||
assert app.warning.getvalue() == ''
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc',
|
||||
|
@ -6,7 +6,7 @@ import pytest
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autosectionlabel')
|
||||
def test_autosectionlabel_html(app, status, warning, skipped_labels=False):
|
||||
def test_autosectionlabel_html(app, skipped_labels=False):
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -44,13 +44,13 @@ def test_autosectionlabel_html(app, status, warning, skipped_labels=False):
|
||||
|
||||
# Reuse test definition from above, just change the test root directory
|
||||
@pytest.mark.sphinx('html', testroot='ext-autosectionlabel-prefix-document')
|
||||
def test_autosectionlabel_prefix_document_html(app, status, warning):
|
||||
test_autosectionlabel_html(app, status, warning)
|
||||
def test_autosectionlabel_prefix_document_html(app):
|
||||
test_autosectionlabel_html(app)
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autosectionlabel',
|
||||
confoverrides={'autosectionlabel_maxdepth': 3})
|
||||
def test_autosectionlabel_maxdepth(app, status, warning):
|
||||
def test_autosectionlabel_maxdepth(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -74,4 +74,4 @@ def test_autosectionlabel_maxdepth(app, status, warning):
|
||||
html = '<li><p><span class="xref std std-ref">Linux</span></p></li>'
|
||||
assert re.search(html, content, re.DOTALL)
|
||||
|
||||
assert "WARNING: undefined label: 'linux'" in warning.getvalue()
|
||||
assert "WARNING: undefined label: 'linux'" in app.warning.getvalue()
|
||||
|
@ -206,7 +206,7 @@ def str_content(elem):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('xml', **default_kw)
|
||||
def test_escaping(app, status, warning):
|
||||
def test_escaping(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
outdir = Path(app.builder.outdir)
|
||||
@ -357,7 +357,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):
|
||||
def test_autosummary_generate(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
doctree = app.env.get_doctree('index')
|
||||
@ -488,7 +488,7 @@ def test_autosummary_generate_overwrite2(app_params, make_app):
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='ext-autosummary-recursive')
|
||||
@pytest.mark.usefixtures("rollback_sysmodules")
|
||||
def test_autosummary_recursive(app, status, warning):
|
||||
def test_autosummary_recursive(app):
|
||||
sys.modules.pop('package', None) # unload target module to clear the module cache
|
||||
|
||||
app.build()
|
||||
@ -526,7 +526,7 @@ def test_autosummary_recursive(app, status, warning):
|
||||
srcdir='test_autosummary_recursive_skips_mocked_modules',
|
||||
confoverrides={'autosummary_mock_imports': ['package.package']})
|
||||
@pytest.mark.usefixtures("rollback_sysmodules")
|
||||
def test_autosummary_recursive_skips_mocked_modules(app, status, warning):
|
||||
def test_autosummary_recursive_skips_mocked_modules(app):
|
||||
sys.modules.pop('package', None) # unload target module to clear the module cache
|
||||
app.build()
|
||||
|
||||
@ -537,7 +537,7 @@ def test_autosummary_recursive_skips_mocked_modules(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='ext-autosummary-filename-map')
|
||||
def test_autosummary_filename_map(app, status, warning):
|
||||
def test_autosummary_filename_map(app):
|
||||
app.build()
|
||||
|
||||
assert (app.srcdir / 'generated' / 'module_mangled.rst').exists()
|
||||
@ -551,11 +551,11 @@ def test_autosummary_filename_map(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', **default_kw)
|
||||
def test_autosummary_latex_table_colspec(app, status, warning):
|
||||
def test_autosummary_latex_table_colspec(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
assert r'\begin{longtable}{\X{1}{2}\X{1}{2}}' in result
|
||||
assert r'p{0.5\linewidth}' not in result
|
||||
|
||||
@ -585,10 +585,10 @@ def test_import_by_name():
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='ext-autosummary-mock_imports')
|
||||
def test_autosummary_mock_imports(app, status, warning):
|
||||
def test_autosummary_mock_imports(app):
|
||||
try:
|
||||
app.build()
|
||||
assert warning.getvalue() == ''
|
||||
assert app.warning.getvalue() == ''
|
||||
|
||||
# generated/foo is generated successfully
|
||||
assert app.env.get_doctree('generated/foo')
|
||||
@ -597,7 +597,7 @@ def test_autosummary_mock_imports(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='ext-autosummary-imported_members')
|
||||
def test_autosummary_imported_members(app, status, warning):
|
||||
def test_autosummary_imported_members(app):
|
||||
try:
|
||||
app.build()
|
||||
# generated/foo is generated successfully
|
||||
@ -617,7 +617,7 @@ def test_autosummary_imported_members(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='ext-autosummary-module_all')
|
||||
def test_autosummary_module_all(app, status, warning):
|
||||
def test_autosummary_module_all(app):
|
||||
try:
|
||||
app.build()
|
||||
# generated/foo is generated successfully
|
||||
@ -675,16 +675,16 @@ def test_autosummary_template(app):
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='ext-autosummary',
|
||||
confoverrides={'autosummary_generate': []})
|
||||
def test_empty_autosummary_generate(app, status, warning):
|
||||
def test_empty_autosummary_generate(app):
|
||||
app.build()
|
||||
assert ("WARNING: autosummary: failed to import autosummary_importfail"
|
||||
in warning.getvalue())
|
||||
in app.warning.getvalue())
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='ext-autosummary',
|
||||
confoverrides={'autosummary_generate': ['unknown']})
|
||||
def test_invalid_autosummary_generate(app, status, warning):
|
||||
assert 'WARNING: autosummary_generate: file not found: unknown.rst' in warning.getvalue()
|
||||
def test_invalid_autosummary_generate(app):
|
||||
assert 'WARNING: autosummary_generate: file not found: unknown.rst' in app.warning.getvalue()
|
||||
|
||||
|
||||
def test_autogen(rootdir, tmp_path):
|
||||
|
@ -10,7 +10,7 @@ from sphinx.testing.util import assert_node
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='ext-autosummary-import_cycle')
|
||||
@pytest.mark.usefixtures("rollback_sysmodules")
|
||||
def test_autosummary_import_cycle(app, warning):
|
||||
def test_autosummary_import_cycle(app):
|
||||
app.build()
|
||||
|
||||
doctree = app.env.get_doctree('index')
|
||||
@ -42,7 +42,7 @@ def test_autosummary_import_cycle(app, warning):
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='ext-autosummary-module_prefix')
|
||||
@pytest.mark.usefixtures("rollback_sysmodules")
|
||||
def test_autosummary_generate_prefixes(app, warning):
|
||||
def test_autosummary_generate_prefixes(app):
|
||||
app.build()
|
||||
warnings = app.warning.getvalue()
|
||||
assert 'Summarised items should not include the current module.' not in warnings
|
||||
|
@ -6,7 +6,7 @@ import pytest
|
||||
|
||||
|
||||
@pytest.mark.sphinx('coverage')
|
||||
def test_build(app, status, warning):
|
||||
def test_build(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
py_undoc = (app.outdir / 'python.txt').read_text(encoding='utf8')
|
||||
@ -22,7 +22,7 @@ def test_build(app, status, warning):
|
||||
|
||||
assert " * mod -- No module named 'mod'" in py_undoc # in the "failed import" section
|
||||
|
||||
assert "undocumented py" not in status.getvalue()
|
||||
assert "undocumented py" not in app.status.getvalue()
|
||||
|
||||
c_undoc = (app.outdir / 'c.txt').read_text(encoding='utf8')
|
||||
assert c_undoc.startswith(
|
||||
@ -44,11 +44,11 @@ def test_build(app, status, warning):
|
||||
assert 'Class' in undoc_py['autodoc_target']['classes']
|
||||
assert 'undocmeth' in undoc_py['autodoc_target']['classes']['Class']
|
||||
|
||||
assert "undocumented c" not in status.getvalue()
|
||||
assert "undocumented c" not in app.status.getvalue()
|
||||
|
||||
|
||||
@pytest.mark.sphinx('coverage', testroot='ext-coverage')
|
||||
def test_coverage_ignore_pyobjects(app, status, warning):
|
||||
def test_coverage_ignore_pyobjects(app):
|
||||
app.build(force_all=True)
|
||||
actual = (app.outdir / 'python.txt').read_text(encoding='utf8')
|
||||
expected = '''\
|
||||
@ -91,25 +91,25 @@ Classes:
|
||||
|
||||
|
||||
@pytest.mark.sphinx('coverage', confoverrides={'coverage_show_missing_items': True})
|
||||
def test_show_missing_items(app, status, warning):
|
||||
def test_show_missing_items(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
assert "undocumented" in status.getvalue()
|
||||
assert "undocumented" in app.status.getvalue()
|
||||
|
||||
assert "py function raises" in status.getvalue()
|
||||
assert "py class Base" in status.getvalue()
|
||||
assert "py method Class.roger" in status.getvalue()
|
||||
assert "py function raises" in app.status.getvalue()
|
||||
assert "py class Base" in app.status.getvalue()
|
||||
assert "py method Class.roger" in app.status.getvalue()
|
||||
|
||||
assert "c api Py_SphinxTest [ function]" in status.getvalue()
|
||||
assert "c api Py_SphinxTest [ function]" in app.status.getvalue()
|
||||
|
||||
|
||||
@pytest.mark.sphinx('coverage', confoverrides={'coverage_show_missing_items': True})
|
||||
def test_show_missing_items_quiet(app, status, warning):
|
||||
def test_show_missing_items_quiet(app):
|
||||
app.quiet = True
|
||||
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()
|
||||
assert "undocumented python method: autodoc_target :: Class :: roger" in warning.getvalue()
|
||||
assert "undocumented python function: autodoc_target :: raises" in app.warning.getvalue()
|
||||
assert "undocumented python class: autodoc_target :: Base" in app.warning.getvalue()
|
||||
assert "undocumented python method: autodoc_target :: Class :: roger" in app.warning.getvalue()
|
||||
|
||||
assert "undocumented c api: Py_SphinxTest [function]" in warning.getvalue()
|
||||
assert "undocumented c api: Py_SphinxTest [function]" in app.warning.getvalue()
|
||||
|
@ -13,18 +13,18 @@ cleanup_called = 0
|
||||
|
||||
|
||||
@pytest.mark.sphinx('doctest', testroot='ext-doctest')
|
||||
def test_build(app, status, warning):
|
||||
def test_build(app):
|
||||
global cleanup_called
|
||||
cleanup_called = 0
|
||||
app.build(force_all=True)
|
||||
assert app.statuscode == 0, f'failures in doctests:\n{status.getvalue()}'
|
||||
assert app.statuscode == 0, f'failures in doctests:\n{app.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'
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='ext-doctest')
|
||||
def test_highlight_language_default(app, status, warning):
|
||||
def test_highlight_language_default(app):
|
||||
app.build()
|
||||
doctree = app.env.get_doctree('doctest')
|
||||
for node in doctree.findall(nodes.literal_block):
|
||||
@ -33,7 +33,7 @@ def test_highlight_language_default(app, status, warning):
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='ext-doctest',
|
||||
confoverrides={'highlight_language': 'python'})
|
||||
def test_highlight_language_python3(app, status, warning):
|
||||
def test_highlight_language_python3(app):
|
||||
app.build()
|
||||
doctree = app.env.get_doctree('doctest')
|
||||
for node in doctree.findall(nodes.literal_block):
|
||||
@ -73,7 +73,7 @@ recorded_calls = Counter()
|
||||
|
||||
|
||||
@pytest.mark.sphinx('doctest', testroot='ext-doctest-skipif')
|
||||
def test_skipif(app, status, warning):
|
||||
def test_skipif(app):
|
||||
"""Tests for the :skipif: option
|
||||
|
||||
The tests are separated into a different test root directory since the
|
||||
@ -87,7 +87,7 @@ def test_skipif(app, status, warning):
|
||||
recorded_calls = Counter()
|
||||
app.build(force_all=True)
|
||||
if app.statuscode != 0:
|
||||
raise AssertionError('failures in doctests:' + status.getvalue())
|
||||
raise AssertionError('failures in doctests:' + app.status.getvalue())
|
||||
# The `:skipif:` expressions are always run.
|
||||
# Actual tests and setup/cleanup code is only run if the `:skipif:`
|
||||
# expression evaluates to a False value.
|
||||
@ -119,7 +119,7 @@ def record(directive, part, should_skip):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('doctest', testroot='ext-doctest-with-autodoc')
|
||||
def test_reporting_with_autodoc(app, status, warning, capfd):
|
||||
def test_reporting_with_autodoc(app, capfd):
|
||||
# Patch builder to get a copy of the output
|
||||
written = []
|
||||
app.builder._warn_out = written.append
|
||||
|
@ -7,8 +7,8 @@ import pytest
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='basic',
|
||||
confoverrides={'extensions': ['sphinx.ext.duration']})
|
||||
def test_githubpages(app, status, warning):
|
||||
def test_githubpages(app):
|
||||
app.build()
|
||||
|
||||
assert 'slowest reading durations' in status.getvalue()
|
||||
assert re.search('\\d+\\.\\d{3} index\n', status.getvalue())
|
||||
assert 'slowest reading durations' in app.status.getvalue()
|
||||
assert re.search('\\d+\\.\\d{3} index\n', app.status.getvalue())
|
||||
|
@ -3,15 +3,15 @@ import pytest
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-extlinks-hardcoded-urls',
|
||||
confoverrides={'extlinks_detect_hardcoded_links': False})
|
||||
def test_extlinks_detect_candidates(app, warning):
|
||||
def test_extlinks_detect_candidates(app):
|
||||
app.build()
|
||||
assert warning.getvalue() == ''
|
||||
assert app.warning.getvalue() == ''
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-extlinks-hardcoded-urls')
|
||||
def test_replaceable_uris_emit_extlinks_warnings(app, warning):
|
||||
def test_replaceable_uris_emit_extlinks_warnings(app):
|
||||
app.build()
|
||||
warning_output = warning.getvalue()
|
||||
warning_output = app.warning.getvalue()
|
||||
|
||||
# there should be exactly three warnings for replaceable URLs
|
||||
message = (
|
||||
@ -24,9 +24,9 @@ def test_replaceable_uris_emit_extlinks_warnings(app, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-extlinks-hardcoded-urls-multiple-replacements')
|
||||
def test_all_replacements_suggested_if_multiple_replacements_possible(app, warning):
|
||||
def test_all_replacements_suggested_if_multiple_replacements_possible(app):
|
||||
app.build()
|
||||
warning_output = warning.getvalue()
|
||||
warning_output = app.warning.getvalue()
|
||||
# there should be six warnings for replaceable URLs, three pairs per link
|
||||
assert warning_output.count("WARNING: hardcoded link") == 6
|
||||
message = (
|
||||
|
@ -4,7 +4,7 @@ import pytest
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-githubpages')
|
||||
def test_githubpages(app, status, warning):
|
||||
def test_githubpages(app):
|
||||
app.build(force_all=True)
|
||||
assert (app.outdir / '.nojekyll').exists()
|
||||
assert not (app.outdir / 'CNAME').exists()
|
||||
@ -12,7 +12,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):
|
||||
def test_no_cname_for_github_io_domain(app):
|
||||
app.build(force_all=True)
|
||||
assert (app.outdir / '.nojekyll').exists()
|
||||
assert not (app.outdir / 'CNAME').exists()
|
||||
@ -20,7 +20,7 @@ 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):
|
||||
def test_cname_for_custom_domain(app):
|
||||
app.build(force_all=True)
|
||||
assert (app.outdir / '.nojekyll').exists()
|
||||
assert (app.outdir / 'CNAME').read_text(encoding='utf8') == 'sphinx-doc.org'
|
||||
|
@ -10,7 +10,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):
|
||||
def test_graphviz_png_html(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -43,7 +43,7 @@ def test_graphviz_png_html(app, status, warning):
|
||||
@pytest.mark.sphinx('html', testroot='ext-graphviz',
|
||||
confoverrides={'graphviz_output_format': 'svg'})
|
||||
@pytest.mark.usefixtures('if_graphviz_found')
|
||||
def test_graphviz_svg_html(app, status, warning):
|
||||
def test_graphviz_svg_html(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -102,7 +102,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):
|
||||
def test_graphviz_latex(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
@ -128,7 +128,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):
|
||||
def test_graphviz_i18n(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
|
@ -8,7 +8,7 @@ from sphinx.testing import restructuredtext
|
||||
|
||||
|
||||
@pytest.mark.sphinx('text', testroot='ext-ifconfig')
|
||||
def test_ifconfig(app, status, warning):
|
||||
def test_ifconfig(app):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'index.txt').read_text(encoding='utf8')
|
||||
assert 'spam' in result
|
||||
|
@ -21,7 +21,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):
|
||||
def test_ext_imgconverter(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
|
@ -4,7 +4,7 @@ import pytest
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='ext-imgmockconverter')
|
||||
def test_ext_imgmockconverter(app, status, warning):
|
||||
def test_ext_imgmockconverter(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
|
@ -17,7 +17,7 @@ from sphinx.ext.intersphinx import load_mappings, validate_intersphinx_mapping
|
||||
|
||||
@pytest.mark.sphinx(buildername="html", testroot="inheritance")
|
||||
@pytest.mark.usefixtures('if_graphviz_found')
|
||||
def test_inheritance_diagram(app, status, warning):
|
||||
def test_inheritance_diagram(app):
|
||||
# monkey-patch InheritaceDiagram.run() so we can get access to its
|
||||
# results.
|
||||
orig_run = InheritanceDiagram.run
|
||||
@ -39,7 +39,7 @@ def test_inheritance_diagram(app, status, warning):
|
||||
|
||||
assert app.statuscode == 0
|
||||
|
||||
html_warnings = warning.getvalue()
|
||||
html_warnings = app.warning.getvalue()
|
||||
assert html_warnings == ""
|
||||
|
||||
# note: it is better to split these asserts into separate test functions
|
||||
@ -248,7 +248,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):
|
||||
def test_inheritance_diagram_latex(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
@ -262,7 +262,7 @@ def test_inheritance_diagram_latex(app, status, warning):
|
||||
@pytest.mark.sphinx('html', testroot='ext-inheritance_diagram',
|
||||
srcdir='ext-inheritance_diagram-alias')
|
||||
@pytest.mark.usefixtures('if_graphviz_found')
|
||||
def test_inheritance_diagram_latex_alias(app, status, warning):
|
||||
def test_inheritance_diagram_latex_alias(app):
|
||||
app.config.inheritance_alias = {'test.Foo': 'alias.Foo'}
|
||||
app.build(force_all=True)
|
||||
|
||||
|
@ -64,49 +64,49 @@ def set_config(app, mapping):
|
||||
|
||||
@mock.patch('sphinx.ext.intersphinx._load.InventoryFile')
|
||||
@mock.patch('sphinx.ext.intersphinx._load._read_from_url')
|
||||
def test_fetch_inventory_redirection(_read_from_url, InventoryFile, app, status, warning): # NoQA: PT019
|
||||
def test_fetch_inventory_redirection(_read_from_url, InventoryFile, app): # NoQA: PT019
|
||||
intersphinx_setup(app)
|
||||
_read_from_url().readline.return_value = b'# Sphinx inventory version 2'
|
||||
|
||||
# same uri and inv, not redirected
|
||||
_read_from_url().url = 'https://hostname/' + INVENTORY_FILENAME
|
||||
fetch_inventory(app, 'https://hostname/', 'https://hostname/' + INVENTORY_FILENAME)
|
||||
assert 'intersphinx inventory has moved' not in status.getvalue()
|
||||
assert 'intersphinx inventory has moved' not in app.status.getvalue()
|
||||
assert InventoryFile.load.call_args[0][1] == 'https://hostname/'
|
||||
|
||||
# same uri and inv, redirected
|
||||
status.seek(0)
|
||||
status.truncate(0)
|
||||
app.status.seek(0)
|
||||
app.status.truncate(0)
|
||||
_read_from_url().url = 'https://hostname/new/' + INVENTORY_FILENAME
|
||||
|
||||
fetch_inventory(app, 'https://hostname/', 'https://hostname/' + INVENTORY_FILENAME)
|
||||
assert status.getvalue() == ('intersphinx inventory has moved: '
|
||||
'https://hostname/%s -> https://hostname/new/%s\n' %
|
||||
(INVENTORY_FILENAME, INVENTORY_FILENAME))
|
||||
assert app.status.getvalue() == ('intersphinx inventory has moved: '
|
||||
'https://hostname/%s -> https://hostname/new/%s\n' %
|
||||
(INVENTORY_FILENAME, INVENTORY_FILENAME))
|
||||
assert InventoryFile.load.call_args[0][1] == 'https://hostname/new'
|
||||
|
||||
# different uri and inv, not redirected
|
||||
status.seek(0)
|
||||
status.truncate(0)
|
||||
app.status.seek(0)
|
||||
app.status.truncate(0)
|
||||
_read_from_url().url = 'https://hostname/new/' + INVENTORY_FILENAME
|
||||
|
||||
fetch_inventory(app, 'https://hostname/', 'https://hostname/new/' + INVENTORY_FILENAME)
|
||||
assert 'intersphinx inventory has moved' not in status.getvalue()
|
||||
assert 'intersphinx inventory has moved' not in app.status.getvalue()
|
||||
assert InventoryFile.load.call_args[0][1] == 'https://hostname/'
|
||||
|
||||
# different uri and inv, redirected
|
||||
status.seek(0)
|
||||
status.truncate(0)
|
||||
app.status.seek(0)
|
||||
app.status.truncate(0)
|
||||
_read_from_url().url = 'https://hostname/other/' + INVENTORY_FILENAME
|
||||
|
||||
fetch_inventory(app, 'https://hostname/', 'https://hostname/new/' + INVENTORY_FILENAME)
|
||||
assert status.getvalue() == ('intersphinx inventory has moved: '
|
||||
'https://hostname/new/%s -> https://hostname/other/%s\n' %
|
||||
(INVENTORY_FILENAME, INVENTORY_FILENAME))
|
||||
assert app.status.getvalue() == ('intersphinx inventory has moved: '
|
||||
'https://hostname/new/%s -> https://hostname/other/%s\n' %
|
||||
(INVENTORY_FILENAME, INVENTORY_FILENAME))
|
||||
assert InventoryFile.load.call_args[0][1] == 'https://hostname/'
|
||||
|
||||
|
||||
def test_missing_reference(tmp_path, app, status, warning):
|
||||
def test_missing_reference(tmp_path, app):
|
||||
inv_file = tmp_path / 'inventory'
|
||||
inv_file.write_bytes(INVENTORY_V2)
|
||||
set_config(app, {
|
||||
@ -184,7 +184,7 @@ def test_missing_reference(tmp_path, app, status, warning):
|
||||
assert rn['refuri'] == 'https://docs.python.org/docname.html'
|
||||
|
||||
|
||||
def test_missing_reference_pydomain(tmp_path, app, status, warning):
|
||||
def test_missing_reference_pydomain(tmp_path, app):
|
||||
inv_file = tmp_path / 'inventory'
|
||||
inv_file.write_bytes(INVENTORY_V2)
|
||||
set_config(app, {
|
||||
@ -214,7 +214,7 @@ def test_missing_reference_pydomain(tmp_path, app, status, warning):
|
||||
assert rn.astext() == 'Foo.bar'
|
||||
|
||||
|
||||
def test_missing_reference_stddomain(tmp_path, app, status, warning):
|
||||
def test_missing_reference_stddomain(tmp_path, app):
|
||||
inv_file = tmp_path / 'inventory'
|
||||
inv_file.write_bytes(INVENTORY_V2)
|
||||
set_config(app, {
|
||||
@ -264,7 +264,7 @@ def test_missing_reference_stddomain(tmp_path, app, status, warning):
|
||||
assert rn.astext() == 'The Julia Domain'
|
||||
|
||||
|
||||
def test_ambiguous_reference_warning(tmp_path, app, warning):
|
||||
def test_ambiguous_reference_warning(tmp_path, app):
|
||||
inv_file = tmp_path / 'inventory'
|
||||
inv_file.write_bytes(INVENTORY_V2_AMBIGUOUS_TERMS)
|
||||
set_config(app, {
|
||||
@ -279,11 +279,11 @@ def test_ambiguous_reference_warning(tmp_path, app, warning):
|
||||
node, contnode = fake_node('std', 'term', 'A TERM', 'A TERM')
|
||||
missing_reference(app, app.env, node, contnode)
|
||||
|
||||
assert 'multiple matches found for std:term:A TERM' in warning.getvalue()
|
||||
assert 'multiple matches found for std:term:A TERM' in app.warning.getvalue()
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-intersphinx-cppdomain')
|
||||
def test_missing_reference_cppdomain(tmp_path, app, status, warning):
|
||||
def test_missing_reference_cppdomain(tmp_path, app):
|
||||
inv_file = tmp_path / 'inventory'
|
||||
inv_file.write_bytes(INVENTORY_V2)
|
||||
set_config(app, {
|
||||
@ -309,7 +309,7 @@ def test_missing_reference_cppdomain(tmp_path, app, status, warning):
|
||||
' title="(in foo v2.0)"><span class="n"><span class="pre">bartype</span></span></a>' in html)
|
||||
|
||||
|
||||
def test_missing_reference_jsdomain(tmp_path, app, status, warning):
|
||||
def test_missing_reference_jsdomain(tmp_path, app):
|
||||
inv_file = tmp_path / 'inventory'
|
||||
inv_file.write_bytes(INVENTORY_V2)
|
||||
set_config(app, {
|
||||
@ -333,7 +333,7 @@ def test_missing_reference_jsdomain(tmp_path, app, status, warning):
|
||||
assert rn.astext() == 'baz()'
|
||||
|
||||
|
||||
def test_missing_reference_disabled_domain(tmp_path, app, status, warning):
|
||||
def test_missing_reference_disabled_domain(tmp_path, app):
|
||||
inv_file = tmp_path / 'inventory'
|
||||
inv_file.write_bytes(INVENTORY_V2)
|
||||
set_config(app, {
|
||||
@ -395,7 +395,7 @@ def test_missing_reference_disabled_domain(tmp_path, app, status, warning):
|
||||
case(term=False, doc=False, py=False)
|
||||
|
||||
|
||||
def test_inventory_not_having_version(tmp_path, app, status, warning):
|
||||
def test_inventory_not_having_version(tmp_path, app):
|
||||
inv_file = tmp_path / 'inventory'
|
||||
inv_file.write_bytes(INVENTORY_V2_NO_VERSION)
|
||||
set_config(app, {
|
||||
@ -413,7 +413,7 @@ def test_inventory_not_having_version(tmp_path, app, status, warning):
|
||||
assert rn[0].astext() == 'Long Module desc'
|
||||
|
||||
|
||||
def test_validate_intersphinx_mapping_warnings(app, warning):
|
||||
def test_validate_intersphinx_mapping_warnings(app):
|
||||
"""Check warnings in :func:`sphinx.ext.intersphinx.validate_intersphinx_mapping`."""
|
||||
bad_intersphinx_mapping = {
|
||||
# fmt: off
|
||||
@ -446,7 +446,7 @@ def test_validate_intersphinx_mapping_warnings(app, warning):
|
||||
match=r'^Invalid `intersphinx_mapping` configuration \(16 errors\).$',
|
||||
):
|
||||
validate_intersphinx_mapping(app, app.config)
|
||||
warnings = strip_colors(warning.getvalue()).splitlines()
|
||||
warnings = strip_colors(app.warning.getvalue()).splitlines()
|
||||
assert len(warnings) == len(bad_intersphinx_mapping) - 3
|
||||
assert warnings == [
|
||||
"ERROR: Invalid intersphinx project identifier `''` in intersphinx_mapping. Project identifiers must be non-empty strings.",
|
||||
@ -468,7 +468,7 @@ def test_validate_intersphinx_mapping_warnings(app, warning):
|
||||
]
|
||||
|
||||
|
||||
def test_load_mappings_fallback(tmp_path, app, status, warning):
|
||||
def test_load_mappings_fallback(tmp_path, app):
|
||||
inv_file = tmp_path / 'inventory'
|
||||
inv_file.write_bytes(INVENTORY_V2)
|
||||
set_config(app, {})
|
||||
@ -479,14 +479,14 @@ def test_load_mappings_fallback(tmp_path, app, status, warning):
|
||||
}
|
||||
validate_intersphinx_mapping(app, app.config)
|
||||
load_mappings(app)
|
||||
assert "failed to reach any of the inventories" in warning.getvalue()
|
||||
assert "failed to reach any of the inventories" in app.warning.getvalue()
|
||||
|
||||
rn = reference_check(app, 'py', 'func', 'module1.func', 'foo')
|
||||
assert rn is None
|
||||
|
||||
# clear messages
|
||||
status.truncate(0)
|
||||
warning.truncate(0)
|
||||
app.status.truncate(0)
|
||||
app.warning.truncate(0)
|
||||
|
||||
# add fallbacks to mapping
|
||||
app.config.intersphinx_mapping = {
|
||||
@ -495,8 +495,8 @@ def test_load_mappings_fallback(tmp_path, app, status, warning):
|
||||
}
|
||||
validate_intersphinx_mapping(app, app.config)
|
||||
load_mappings(app)
|
||||
assert "encountered some issues with some of the inventories" in status.getvalue()
|
||||
assert warning.getvalue() == ""
|
||||
assert "encountered some issues with some of the inventories" in app.status.getvalue()
|
||||
assert app.warning.getvalue() == ""
|
||||
|
||||
rn = reference_check(app, 'py', 'func', 'module1.func', 'foo')
|
||||
assert isinstance(rn, nodes.reference)
|
||||
@ -600,7 +600,7 @@ def test_inspect_main_url(capsys):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-intersphinx-role')
|
||||
def test_intersphinx_role(app, warning):
|
||||
def test_intersphinx_role(app):
|
||||
inv_file = app.srcdir / 'inventory'
|
||||
inv_file.write_bytes(INVENTORY_V2)
|
||||
app.config.intersphinx_mapping = {
|
||||
@ -615,7 +615,7 @@ def test_intersphinx_role(app, warning):
|
||||
|
||||
app.build()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
warnings = strip_colors(warning.getvalue()).splitlines()
|
||||
warnings = strip_colors(app.warning.getvalue()).splitlines()
|
||||
index_path = app.srcdir / 'index.rst'
|
||||
assert warnings == [
|
||||
f"{index_path}:21: WARNING: role for external cross-reference not found in domain 'py': 'nope' [intersphinx.external]",
|
||||
|
@ -26,12 +26,12 @@ def has_binary(binary: str) -> bool:
|
||||
reason='Requires dvipng" binary')
|
||||
@pytest.mark.sphinx('html', testroot='ext-math-simple',
|
||||
confoverrides={'extensions': ['sphinx.ext.imgmath']})
|
||||
def test_imgmath_png(app, status, warning):
|
||||
def test_imgmath_png(app):
|
||||
app.build(force_all=True)
|
||||
if "LaTeX command 'latex' cannot be run" in warning.getvalue():
|
||||
if "LaTeX command 'latex' cannot be run" in app.warning.getvalue():
|
||||
msg = 'LaTeX command "latex" is not available'
|
||||
raise pytest.skip.Exception(msg)
|
||||
if "dvipng command 'dvipng' cannot be run" in warning.getvalue():
|
||||
if "dvipng command 'dvipng' cannot be run" in app.warning.getvalue():
|
||||
msg = 'dvipng command "dvipng" is not available'
|
||||
raise pytest.skip.Exception(msg)
|
||||
|
||||
@ -47,12 +47,12 @@ def test_imgmath_png(app, status, warning):
|
||||
@pytest.mark.sphinx('html', testroot='ext-math-simple',
|
||||
confoverrides={'extensions': ['sphinx.ext.imgmath'],
|
||||
'imgmath_image_format': 'svg'})
|
||||
def test_imgmath_svg(app, status, warning):
|
||||
def test_imgmath_svg(app):
|
||||
app.build(force_all=True)
|
||||
if "LaTeX command 'latex' cannot be run" in warning.getvalue():
|
||||
if "LaTeX command 'latex' cannot be run" in app.warning.getvalue():
|
||||
msg = 'LaTeX command "latex" is not available'
|
||||
raise pytest.skip.Exception(msg)
|
||||
if "dvisvgm command 'dvisvgm' cannot be run" in warning.getvalue():
|
||||
if "dvisvgm command 'dvisvgm' cannot be run" in app.warning.getvalue():
|
||||
msg = 'dvisvgm command "dvisvgm" is not available'
|
||||
raise pytest.skip.Exception(msg)
|
||||
|
||||
@ -69,12 +69,12 @@ def test_imgmath_svg(app, status, warning):
|
||||
confoverrides={'extensions': ['sphinx.ext.imgmath'],
|
||||
'imgmath_image_format': 'svg',
|
||||
'imgmath_embed': True})
|
||||
def test_imgmath_svg_embed(app, status, warning):
|
||||
def test_imgmath_svg_embed(app):
|
||||
app.build(force_all=True)
|
||||
if "LaTeX command 'latex' cannot be run" in warning.getvalue():
|
||||
if "LaTeX command 'latex' cannot be run" in app.warning.getvalue():
|
||||
msg = 'LaTeX command "latex" is not available'
|
||||
raise pytest.skip.Exception(msg)
|
||||
if "dvisvgm command 'dvisvgm' cannot be run" in warning.getvalue():
|
||||
if "dvisvgm command 'dvisvgm' cannot be run" in app.warning.getvalue():
|
||||
msg = 'dvisvgm command "dvisvgm" is not available'
|
||||
raise pytest.skip.Exception(msg)
|
||||
|
||||
@ -87,7 +87,7 @@ def test_imgmath_svg_embed(app, status, warning):
|
||||
@pytest.mark.sphinx('html', testroot='ext-math',
|
||||
confoverrides={'extensions': ['sphinx.ext.mathjax'],
|
||||
'mathjax_options': {'integrity': 'sha384-0123456789'}})
|
||||
def test_mathjax_options(app, status, warning):
|
||||
def test_mathjax_options(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -99,7 +99,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):
|
||||
def test_mathjax_align(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -113,7 +113,7 @@ def test_mathjax_align(app, status, warning):
|
||||
@pytest.mark.sphinx('html', testroot='ext-math',
|
||||
confoverrides={'math_number_all': True,
|
||||
'extensions': ['sphinx.ext.mathjax']})
|
||||
def test_math_number_all_mathjax(app, status, warning):
|
||||
def test_math_number_all_mathjax(app):
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -124,7 +124,7 @@ def test_math_number_all_mathjax(app, status, warning):
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='ext-math',
|
||||
confoverrides={'extensions': ['sphinx.ext.mathjax']})
|
||||
def test_math_number_all_latex(app, status, warning):
|
||||
def test_math_number_all_latex(app):
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
@ -154,7 +154,7 @@ def test_math_number_all_latex(app, status, warning):
|
||||
@pytest.mark.sphinx('html', testroot='ext-math',
|
||||
confoverrides={'extensions': ['sphinx.ext.mathjax'],
|
||||
'math_eqref_format': 'Eq.{number}'})
|
||||
def test_math_eqref_format_html(app, status, warning):
|
||||
def test_math_eqref_format_html(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'math.html').read_text(encoding='utf8')
|
||||
@ -167,7 +167,7 @@ def test_math_eqref_format_html(app, status, warning):
|
||||
@pytest.mark.sphinx('latex', testroot='ext-math',
|
||||
confoverrides={'extensions': ['sphinx.ext.mathjax'],
|
||||
'math_eqref_format': 'Eq.{number}'})
|
||||
def test_math_eqref_format_latex(app, status, warning):
|
||||
def test_math_eqref_format_latex(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
@ -180,7 +180,7 @@ def test_math_eqref_format_latex(app, status, warning):
|
||||
confoverrides={'extensions': ['sphinx.ext.mathjax'],
|
||||
'numfig': True,
|
||||
'math_numfig': True})
|
||||
def test_mathjax_numfig_html(app, status, warning):
|
||||
def test_mathjax_numfig_html(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'math.html').read_text(encoding='utf8')
|
||||
@ -198,7 +198,7 @@ def test_mathjax_numfig_html(app, status, warning):
|
||||
'numfig': True,
|
||||
'math_numfig': True,
|
||||
'math_numsep': '-'})
|
||||
def test_mathjax_numsep_html(app, status, warning):
|
||||
def test_mathjax_numsep_html(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'math.html').read_text(encoding='utf8')
|
||||
@ -216,7 +216,7 @@ def test_mathjax_numsep_html(app, status, warning):
|
||||
'numfig': True,
|
||||
'numfig_secnum_depth': 0,
|
||||
'math_numfig': True})
|
||||
def test_imgmath_numfig_html(app, status, warning):
|
||||
def test_imgmath_numfig_html(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'page.html').read_text(encoding='utf8')
|
||||
@ -229,7 +229,7 @@ def test_imgmath_numfig_html(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='ext-math-compat')
|
||||
def test_math_compat(app, status, warning):
|
||||
def test_math_compat(app):
|
||||
with warnings.catch_warnings(record=True):
|
||||
app.build(force_all=True)
|
||||
doctree = app.env.get_and_resolve_doctree('index', app.builder)
|
||||
@ -256,7 +256,7 @@ def test_math_compat(app, status, warning):
|
||||
@pytest.mark.sphinx('html', testroot='ext-math',
|
||||
confoverrides={'extensions': ['sphinx.ext.mathjax'],
|
||||
'mathjax3_config': {'extensions': ['tex2jax.js']}})
|
||||
def test_mathjax3_config(app, status, warning):
|
||||
def test_mathjax3_config(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -268,7 +268,7 @@ def test_mathjax3_config(app, status, warning):
|
||||
@pytest.mark.sphinx('html', testroot='ext-math',
|
||||
confoverrides={'extensions': ['sphinx.ext.mathjax'],
|
||||
'mathjax2_config': {'extensions': ['tex2jax.js']}})
|
||||
def test_mathjax2_config(app, status, warning):
|
||||
def test_mathjax2_config(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -282,7 +282,7 @@ def test_mathjax2_config(app, status, warning):
|
||||
confoverrides={'extensions': ['sphinx.ext.mathjax'],
|
||||
'mathjax_options': {'async': 'async'},
|
||||
'mathjax3_config': {'extensions': ['tex2jax.js']}})
|
||||
def test_mathjax_options_async_for_mathjax3(app, status, warning):
|
||||
def test_mathjax_options_async_for_mathjax3(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -294,7 +294,7 @@ def test_mathjax_options_async_for_mathjax3(app, status, warning):
|
||||
confoverrides={'extensions': ['sphinx.ext.mathjax'],
|
||||
'mathjax_options': {'defer': 'defer'},
|
||||
'mathjax2_config': {'extensions': ['tex2jax.js']}})
|
||||
def test_mathjax_options_defer_for_mathjax2(app, status, warning):
|
||||
def test_mathjax_options_defer_for_mathjax2(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -331,7 +331,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):
|
||||
def test_mathjax_is_installed_only_if_document_having_math(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -343,7 +343,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):
|
||||
def test_mathjax_is_not_installed_if_no_equations(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -352,7 +352,7 @@ def test_mathjax_is_not_installed_if_no_equations(app, status, warning):
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-math',
|
||||
confoverrides={'extensions': ['sphinx.ext.mathjax']})
|
||||
def test_mathjax_is_installed_if_no_equations_when_forced(app, status, warning):
|
||||
def test_mathjax_is_installed_if_no_equations_when_forced(app):
|
||||
app.set_html_assets_policy('always')
|
||||
app.build(force_all=True)
|
||||
|
||||
|
@ -2552,7 +2552,7 @@ definition_after_normal_text : int
|
||||
actual = str(NumpyDocstring(docstring, config))
|
||||
assert expected == actual
|
||||
|
||||
def test_token_type_invalid(self, warning):
|
||||
def test_token_type_invalid(self, app):
|
||||
tokens = (
|
||||
"{1, 2",
|
||||
"}",
|
||||
@ -2573,12 +2573,12 @@ definition_after_normal_text : int
|
||||
try:
|
||||
_token_type(token)
|
||||
finally:
|
||||
raw_warnings = warning.getvalue()
|
||||
raw_warnings = app.warning.getvalue()
|
||||
warnings = [w for w in raw_warnings.split("\n") if w.strip()]
|
||||
|
||||
assert len(warnings) == 1
|
||||
assert re.compile(error).match(warnings[0])
|
||||
warning.truncate(0)
|
||||
app.warning.truncate(0)
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("name", "expected"),
|
||||
@ -2623,7 +2623,7 @@ Sample class with PEP 526 annotations and numpy docstring
|
||||
@pytest.mark.sphinx('text', testroot='ext-napoleon',
|
||||
confoverrides={'autodoc_typehints': 'description',
|
||||
'autodoc_typehints_description_target': 'all'})
|
||||
def test_napoleon_and_autodoc_typehints_description_all(app, status, warning):
|
||||
def test_napoleon_and_autodoc_typehints_description_all(app):
|
||||
app.build()
|
||||
content = (app.outdir / 'typehints.txt').read_text(encoding='utf-8')
|
||||
assert content == (
|
||||
@ -2647,7 +2647,7 @@ def test_napoleon_and_autodoc_typehints_description_all(app, status, warning):
|
||||
@pytest.mark.sphinx('text', testroot='ext-napoleon',
|
||||
confoverrides={'autodoc_typehints': 'description',
|
||||
'autodoc_typehints_description_target': 'documented_params'})
|
||||
def test_napoleon_and_autodoc_typehints_description_documented_params(app, status, warning):
|
||||
def test_napoleon_and_autodoc_typehints_description_documented_params(app):
|
||||
app.build()
|
||||
content = (app.outdir / 'typehints.txt').read_text(encoding='utf-8')
|
||||
assert content == (
|
||||
|
@ -7,7 +7,7 @@ import pytest
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-todo', freshenv=True,
|
||||
confoverrides={'todo_include_todos': True, 'todo_emit_warnings': True})
|
||||
def test_todo(app, status, warning):
|
||||
def test_todo(app):
|
||||
todos = []
|
||||
|
||||
def on_todo_defined(app, node):
|
||||
@ -33,8 +33,8 @@ def test_todo(app, status, warning):
|
||||
'<p>todo in param field</p>') in content
|
||||
|
||||
# check emitted warnings
|
||||
assert 'WARNING: TODO entry found: todo in foo' in warning.getvalue()
|
||||
assert 'WARNING: TODO entry found: todo in bar' in warning.getvalue()
|
||||
assert 'WARNING: TODO entry found: todo in foo' in app.warning.getvalue()
|
||||
assert 'WARNING: TODO entry found: todo in bar' in app.warning.getvalue()
|
||||
|
||||
# check handled event
|
||||
assert len(todos) == 3
|
||||
@ -45,7 +45,7 @@ def test_todo(app, status, warning):
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-todo', freshenv=True,
|
||||
confoverrides={'todo_include_todos': False, 'todo_emit_warnings': True})
|
||||
def test_todo_not_included(app, status, warning):
|
||||
def test_todo_not_included(app):
|
||||
todos = []
|
||||
|
||||
def on_todo_defined(app, node):
|
||||
@ -68,8 +68,8 @@ def test_todo_not_included(app, status, warning):
|
||||
'<p>todo in foo</p>') not in content
|
||||
|
||||
# check emitted warnings
|
||||
assert 'WARNING: TODO entry found: todo in foo' in warning.getvalue()
|
||||
assert 'WARNING: TODO entry found: todo in bar' in warning.getvalue()
|
||||
assert 'WARNING: TODO entry found: todo in foo' in app.warning.getvalue()
|
||||
assert 'WARNING: TODO entry found: todo in bar' in app.warning.getvalue()
|
||||
|
||||
# check handled event
|
||||
assert len(todos) == 3
|
||||
@ -80,7 +80,7 @@ def test_todo_not_included(app, status, warning):
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='ext-todo', freshenv=True,
|
||||
confoverrides={'todo_include_todos': True})
|
||||
def test_todo_valid_link(app, status, warning):
|
||||
def test_todo_valid_link(app):
|
||||
"""
|
||||
Test that the inserted "original entry" links for todo items have a target
|
||||
that exists in the LaTeX output. The target was previously incorrectly
|
||||
|
@ -9,13 +9,11 @@ from typing import TYPE_CHECKING
|
||||
import pytest
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from io import StringIO
|
||||
|
||||
from sphinx.application import Sphinx
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
def check_viewcode_output(app: Sphinx, warning: StringIO) -> str:
|
||||
warnings = re.sub(r'\\+', '/', warning.getvalue())
|
||||
def check_viewcode_output(app: SphinxTestApp) -> str:
|
||||
warnings = re.sub(r'\\+', '/', app.warning.getvalue())
|
||||
assert re.findall(
|
||||
r"index.rst:\d+: WARNING: Object named 'func1' not found in include " +
|
||||
r"file .*/spam/__init__.py'",
|
||||
@ -51,28 +49,28 @@ def check_viewcode_output(app: Sphinx, warning: StringIO) -> str:
|
||||
@pytest.mark.sphinx(testroot='ext-viewcode', freshenv=True,
|
||||
confoverrides={"viewcode_line_numbers": True})
|
||||
@pytest.mark.usefixtures("rollback_sysmodules")
|
||||
def test_viewcode_linenos(app, warning):
|
||||
def test_viewcode_linenos(app):
|
||||
shutil.rmtree(app.outdir / '_modules', ignore_errors=True)
|
||||
app.build(force_all=True)
|
||||
|
||||
result = check_viewcode_output(app, warning)
|
||||
result = check_viewcode_output(app)
|
||||
assert '<span class="linenos"> 1</span>' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='ext-viewcode', freshenv=True,
|
||||
confoverrides={"viewcode_line_numbers": False})
|
||||
@pytest.mark.usefixtures("rollback_sysmodules")
|
||||
def test_viewcode(app, warning):
|
||||
def test_viewcode(app):
|
||||
shutil.rmtree(app.outdir / '_modules', ignore_errors=True)
|
||||
app.build(force_all=True)
|
||||
|
||||
result = check_viewcode_output(app, warning)
|
||||
result = check_viewcode_output(app)
|
||||
assert 'class="linenos">' not in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx('epub', testroot='ext-viewcode')
|
||||
@pytest.mark.usefixtures("rollback_sysmodules")
|
||||
def test_viewcode_epub_default(app, status, warning):
|
||||
def test_viewcode_epub_default(app):
|
||||
shutil.rmtree(app.outdir)
|
||||
app.build(force_all=True)
|
||||
|
||||
@ -85,7 +83,7 @@ def test_viewcode_epub_default(app, status, warning):
|
||||
@pytest.mark.sphinx('epub', testroot='ext-viewcode',
|
||||
confoverrides={'viewcode_enable_epub': True})
|
||||
@pytest.mark.usefixtures("rollback_sysmodules")
|
||||
def test_viewcode_epub_enabled(app, status, warning):
|
||||
def test_viewcode_epub_enabled(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
assert (app.outdir / '_modules/spam/mod1.xhtml').exists()
|
||||
@ -95,7 +93,7 @@ def test_viewcode_epub_enabled(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='ext-viewcode', tags=['test_linkcode'])
|
||||
def test_linkcode(app, status, warning):
|
||||
def test_linkcode(app):
|
||||
app.build(filenames=[app.srcdir / 'objects.rst'])
|
||||
|
||||
stuff = (app.outdir / 'objects.html').read_text(encoding='utf8')
|
||||
@ -107,7 +105,7 @@ def test_linkcode(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='ext-viewcode-find', freshenv=True)
|
||||
def test_local_source_files(app, status, warning):
|
||||
def test_local_source_files(app):
|
||||
def find_source(app, modname):
|
||||
if modname == 'not_a_package':
|
||||
source = (app.srcdir / 'not_a_package/__init__.py').read_text(encoding='utf8')
|
||||
@ -131,7 +129,7 @@ def test_local_source_files(app, status, warning):
|
||||
app.connect('viewcode-find-source', find_source)
|
||||
app.build(force_all=True)
|
||||
|
||||
warnings = re.sub(r'\\+', '/', warning.getvalue())
|
||||
warnings = re.sub(r'\\+', '/', app.warning.getvalue())
|
||||
assert re.findall(
|
||||
r"index.rst:\d+: WARNING: Object named 'func1' not found in include " +
|
||||
r"file .*/not_a_package/__init__.py'",
|
||||
|
@ -31,7 +31,7 @@ class ComplainOnUnhighlighted(PygmentsBridge):
|
||||
raise AssertionError("should highlight %r" % source)
|
||||
|
||||
|
||||
def test_add_lexer(app, status, warning):
|
||||
def test_add_lexer(app):
|
||||
app.add_lexer('test', MyLexer)
|
||||
|
||||
bridge = PygmentsBridge('html')
|
||||
|
@ -30,7 +30,7 @@ def _setup_test(app_params):
|
||||
@pytest.mark.sphinx(
|
||||
'html', testroot='intl',
|
||||
confoverrides={'language': 'en', 'locale_dirs': ['./locale']})
|
||||
def test_compile_all_catalogs(app, status, warning):
|
||||
def test_compile_all_catalogs(app):
|
||||
app.builder.compile_all_catalogs()
|
||||
|
||||
locale_dir = app.srcdir / 'locale'
|
||||
@ -46,7 +46,7 @@ def test_compile_all_catalogs(app, status, warning):
|
||||
@pytest.mark.sphinx(
|
||||
'html', testroot='intl',
|
||||
confoverrides={'language': 'en', 'locale_dirs': ['./locale']})
|
||||
def test_compile_specific_catalogs(app, status, warning):
|
||||
def test_compile_specific_catalogs(app):
|
||||
locale_dir = app.srcdir / 'locale'
|
||||
catalog_dir = locale_dir / app.config.language / 'LC_MESSAGES'
|
||||
|
||||
@ -63,7 +63,7 @@ def test_compile_specific_catalogs(app, status, warning):
|
||||
@pytest.mark.sphinx(
|
||||
'html', testroot='intl',
|
||||
confoverrides={'language': 'en', 'locale_dirs': ['./locale']})
|
||||
def test_compile_update_catalogs(app, status, warning):
|
||||
def test_compile_update_catalogs(app):
|
||||
app.builder.compile_update_catalogs()
|
||||
|
||||
locale_dir = app.srcdir / 'locale'
|
||||
|
@ -8,6 +8,7 @@ import os.path
|
||||
import re
|
||||
import shutil
|
||||
import time
|
||||
from io import StringIO
|
||||
|
||||
import pytest
|
||||
from babel.messages import mofile, pofile
|
||||
@ -91,10 +92,10 @@ def assert_count(expected_expr, result, count):
|
||||
@sphinx_intl
|
||||
@pytest.mark.sphinx('text')
|
||||
@pytest.mark.test_params(shared_result='test_intl_basic')
|
||||
def test_text_emit_warnings(app, warning):
|
||||
def test_text_emit_warnings(app):
|
||||
app.build()
|
||||
# test warnings in translation
|
||||
warnings = getwarning(warning)
|
||||
warnings = getwarning(app.warning)
|
||||
warning_expr = ('.*/warnings.txt:4:<translated>:1: '
|
||||
'WARNING: Inline literal start-string without end-string. \\[docutils\\]\n')
|
||||
assert re.search(warning_expr, warnings), f'{warning_expr!r} did not match {warnings!r}'
|
||||
@ -139,7 +140,7 @@ def test_text_subdirs(app):
|
||||
@sphinx_intl
|
||||
@pytest.mark.sphinx('text')
|
||||
@pytest.mark.test_params(shared_result='test_intl_basic')
|
||||
def test_text_inconsistency_warnings(app, warning):
|
||||
def test_text_inconsistency_warnings(app):
|
||||
app.build()
|
||||
# --- check warnings for inconsistency in number of references
|
||||
result = (app.outdir / 'refs_inconsistency.txt').read_text(encoding='utf8')
|
||||
@ -153,7 +154,7 @@ def test_text_inconsistency_warnings(app, warning):
|
||||
"\n[100] THIS IS A NUMBERED FOOTNOTE.\n")
|
||||
assert result == expect
|
||||
|
||||
warnings = getwarning(warning)
|
||||
warnings = getwarning(app.warning)
|
||||
warning_fmt = ('.*/refs_inconsistency.txt:\\d+: '
|
||||
'WARNING: inconsistent %(reftype)s in translated message.'
|
||||
' original: %(original)s, translated: %(translated)s \\[i18n.inconsistent_references\\]\n')
|
||||
@ -192,7 +193,7 @@ def test_text_inconsistency_warnings(app, warning):
|
||||
@sphinx_intl
|
||||
@pytest.mark.sphinx('text')
|
||||
@pytest.mark.test_params(shared_result='test_intl_basic')
|
||||
def test_noqa(app, warning):
|
||||
def test_noqa(app):
|
||||
app.build()
|
||||
result = (app.outdir / 'noqa.txt').read_text(encoding='utf8')
|
||||
expect = r"""FIRST SECTION
|
||||
@ -212,13 +213,13 @@ Some text, again referring to the section: NEXT SECTION WITH PARAGRAPH
|
||||
TO TEST BARE noqa.
|
||||
"""
|
||||
assert result == expect
|
||||
assert "next-section" not in getwarning(warning)
|
||||
assert "next-section" not in getwarning(app.warning)
|
||||
|
||||
|
||||
@sphinx_intl
|
||||
@pytest.mark.sphinx('text')
|
||||
@pytest.mark.test_params(shared_result='test_intl_basic')
|
||||
def test_text_literalblock_warnings(app, warning):
|
||||
def test_text_literalblock_warnings(app):
|
||||
app.build()
|
||||
# --- check warning for literal block
|
||||
result = (app.outdir / 'literalblock.txt').read_text(encoding='utf8')
|
||||
@ -231,7 +232,7 @@ def test_text_literalblock_warnings(app, warning):
|
||||
"\n<SYSTEM MESSAGE:")
|
||||
assert result.startswith(expect)
|
||||
|
||||
warnings = getwarning(warning)
|
||||
warnings = getwarning(app.warning)
|
||||
expected_warning_expr = ('.*/literalblock.txt:\\d+: '
|
||||
'WARNING: Literal block expected; none found.')
|
||||
assert re.search(expected_warning_expr, warnings), f'{expected_warning_expr!r} did not match {warnings!r}'
|
||||
@ -260,7 +261,7 @@ def test_text_definition_terms(app):
|
||||
@sphinx_intl
|
||||
@pytest.mark.sphinx('text')
|
||||
@pytest.mark.test_params(shared_result='test_intl_basic')
|
||||
def test_text_glossary_term(app, warning):
|
||||
def test_text_glossary_term(app):
|
||||
app.build()
|
||||
# --- glossary terms: regression test for #1090
|
||||
result = (app.outdir / 'glossary_terms.txt').read_text(encoding='utf8')
|
||||
@ -288,14 +289,14 @@ VVV
|
||||
DEFINE ZZZ
|
||||
""")
|
||||
assert result == expect
|
||||
warnings = getwarning(warning)
|
||||
warnings = getwarning(app.warning)
|
||||
assert warnings.count('term not in glossary') == 1
|
||||
|
||||
|
||||
@sphinx_intl
|
||||
@pytest.mark.sphinx('text')
|
||||
@pytest.mark.test_params(shared_result='test_intl_basic')
|
||||
def test_text_glossary_term_inconsistencies(app, warning):
|
||||
def test_text_glossary_term_inconsistencies(app):
|
||||
app.build()
|
||||
# --- glossary term inconsistencies: regression test for #1090
|
||||
result = (app.outdir / 'glossary_terms_inconsistency.txt').read_text(encoding='utf8')
|
||||
@ -305,7 +306,7 @@ def test_text_glossary_term_inconsistencies(app, warning):
|
||||
"\n2. LINK TO *TERM NOT IN GLOSSARY*.\n")
|
||||
assert result == expect
|
||||
|
||||
warnings = getwarning(warning)
|
||||
warnings = getwarning(app.warning)
|
||||
expected_warning_expr = (
|
||||
'.*/glossary_terms_inconsistency.txt:\\d+: '
|
||||
'WARNING: inconsistent term references in translated message.'
|
||||
@ -567,14 +568,14 @@ def test_gettext_definition_terms(app):
|
||||
@sphinx_intl
|
||||
@pytest.mark.sphinx('gettext')
|
||||
@pytest.mark.test_params(shared_result='test_intl_gettext')
|
||||
def test_gettext_glossary_terms(app, warning):
|
||||
def test_gettext_glossary_terms(app):
|
||||
app.build()
|
||||
# --- glossary terms: regression test for #1090
|
||||
expect = read_po(app.srcdir / _CATALOG_LOCALE / 'LC_MESSAGES' / 'glossary_terms.po')
|
||||
actual = read_po(app.outdir / 'glossary_terms.pot')
|
||||
for expect_msg in [m for m in expect if m.id]:
|
||||
assert expect_msg.id in [m.id for m in actual if m.id]
|
||||
warnings = warning.getvalue().replace(os.sep, '/')
|
||||
warnings = app.warning.getvalue().replace(os.sep, '/')
|
||||
assert 'term not in glossary' not in warnings
|
||||
|
||||
|
||||
@ -1046,7 +1047,7 @@ def test_html_rebuild_mo(app):
|
||||
@sphinx_intl
|
||||
@pytest.mark.sphinx('xml')
|
||||
@pytest.mark.test_params(shared_result='test_intl_basic')
|
||||
def test_xml_footnotes(app, warning):
|
||||
def test_xml_footnotes(app):
|
||||
app.build()
|
||||
# --- footnotes: regression test for fix #955, #1176
|
||||
et = etree_parse(app.outdir / 'footnote.xml')
|
||||
@ -1092,7 +1093,7 @@ def test_xml_footnotes(app, warning):
|
||||
None,
|
||||
['ref'])
|
||||
|
||||
warnings = getwarning(warning)
|
||||
warnings = getwarning(app.warning)
|
||||
warning_expr = '.*/footnote.xml:\\d*: SEVERE: Duplicate ID: ".*".\n'
|
||||
assert not re.search(warning_expr, warnings), f'{warning_expr!r} did match {warnings!r}'
|
||||
|
||||
@ -1254,10 +1255,10 @@ def test_xml_role_xref(app):
|
||||
@sphinx_intl
|
||||
@pytest.mark.sphinx('xml')
|
||||
@pytest.mark.test_params(shared_result='test_intl_basic')
|
||||
def test_xml_warnings(app, warning):
|
||||
def test_xml_warnings(app):
|
||||
app.build()
|
||||
# warnings
|
||||
warnings = getwarning(warning)
|
||||
warnings = getwarning(app.warning)
|
||||
assert warnings.count('term not in glossary') == 1
|
||||
assert 'undefined label' not in warnings
|
||||
assert 'unknown document' not in warnings
|
||||
@ -1518,10 +1519,10 @@ def test_additional_targets_should_be_translated_substitution_definitions(app):
|
||||
@sphinx_intl
|
||||
@pytest.mark.sphinx('text')
|
||||
@pytest.mark.test_params(shared_result='test_intl_basic')
|
||||
def test_text_references(app, warning):
|
||||
def test_text_references(app):
|
||||
app.build(filenames=[app.srcdir / 'refs.txt'])
|
||||
|
||||
warnings = warning.getvalue().replace(os.sep, '/')
|
||||
warnings = app.warning.getvalue().replace(os.sep, '/')
|
||||
warning_expr = 'refs.txt:\\d+: ERROR: Unknown target name:'
|
||||
assert_count(warning_expr, warnings, 0)
|
||||
|
||||
@ -1642,7 +1643,7 @@ def test_image_glob_intl_using_figure_language_filename(app):
|
||||
'image/svg+xml': 'subdir/svgimg.svg'})
|
||||
|
||||
|
||||
def getwarning(warnings):
|
||||
def getwarning(warnings: StringIO) -> str:
|
||||
return strip_colors(warnings.getvalue().replace(os.sep, '/'))
|
||||
|
||||
|
||||
|
@ -519,7 +519,7 @@ def test_XRefRole(inliner):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='prolog')
|
||||
def test_rst_prolog(app, status, warning):
|
||||
def test_rst_prolog(app):
|
||||
app.build(force_all=True)
|
||||
rst = app.env.get_doctree('restructuredtext')
|
||||
md = app.env.get_doctree('markdown')
|
||||
@ -543,7 +543,7 @@ def test_rst_prolog(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='keep_warnings')
|
||||
def test_keep_warnings_is_True(app, status, warning):
|
||||
def test_keep_warnings_is_True(app):
|
||||
app.build(force_all=True)
|
||||
doctree = app.env.get_doctree('index')
|
||||
assert_node(doctree[0], nodes.section)
|
||||
@ -553,7 +553,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):
|
||||
def test_keep_warnings_is_False(app):
|
||||
app.build(force_all=True)
|
||||
doctree = app.env.get_doctree('index')
|
||||
assert_node(doctree[0], nodes.section)
|
||||
@ -561,7 +561,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):
|
||||
def test_compact_refonly_bullet_list(app):
|
||||
app.build(force_all=True)
|
||||
doctree = app.env.get_doctree('index')
|
||||
assert_node(doctree[0], nodes.section)
|
||||
@ -579,7 +579,7 @@ def test_compact_refonly_bullet_list(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='default_role')
|
||||
def test_default_role1(app, status, warning):
|
||||
def test_default_role1(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
# default-role: pep
|
||||
@ -600,7 +600,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):
|
||||
def test_default_role2(app):
|
||||
app.build(force_all=True)
|
||||
|
||||
# default-role directive is stronger than configratuion
|
||||
|
@ -7,7 +7,7 @@ import pytest
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='metadata')
|
||||
def test_docinfo(app, status, warning):
|
||||
def test_docinfo(app):
|
||||
"""
|
||||
Inspect the 'docinfo' metadata stored in the first node of the document.
|
||||
Note this doesn't give us access to data stored in subsequence blocks
|
||||
|
@ -6,7 +6,7 @@ from sphinx.testing.util import etree_parse
|
||||
|
||||
|
||||
@pytest.mark.sphinx(buildername='html', testroot='smartquotes', freshenv=True)
|
||||
def test_basic(app, status, warning):
|
||||
def test_basic(app):
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -14,7 +14,7 @@ def test_basic(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx(buildername='html', testroot='smartquotes', freshenv=True)
|
||||
def test_literals(app, status, warning):
|
||||
def test_literals(app):
|
||||
app.build()
|
||||
|
||||
etree = etree_parse(app.outdir / 'literals.html')
|
||||
@ -30,7 +30,7 @@ def test_literals(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx(buildername='text', testroot='smartquotes', freshenv=True)
|
||||
def test_text_builder(app, status, warning):
|
||||
def test_text_builder(app):
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'index.txt').read_text(encoding='utf8')
|
||||
@ -38,7 +38,7 @@ def test_text_builder(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx(buildername='man', testroot='smartquotes', freshenv=True)
|
||||
def test_man_builder(app, status, warning):
|
||||
def test_man_builder(app):
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'projectnamenotset.1').read_text(encoding='utf8')
|
||||
@ -46,7 +46,7 @@ def test_man_builder(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx(buildername='latex', testroot='smartquotes', freshenv=True)
|
||||
def test_latex_builder(app, status, warning):
|
||||
def test_latex_builder(app):
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
@ -55,7 +55,7 @@ def test_latex_builder(app, status, warning):
|
||||
|
||||
@pytest.mark.sphinx(buildername='html', testroot='smartquotes', freshenv=True,
|
||||
confoverrides={'language': 'ja'})
|
||||
def test_ja_html_builder(app, status, warning):
|
||||
def test_ja_html_builder(app):
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -64,7 +64,7 @@ def test_ja_html_builder(app, status, warning):
|
||||
|
||||
@pytest.mark.sphinx(buildername='html', testroot='smartquotes', freshenv=True,
|
||||
confoverrides={'smartquotes': False})
|
||||
def test_smartquotes_disabled(app, status, warning):
|
||||
def test_smartquotes_disabled(app):
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -73,7 +73,7 @@ def test_smartquotes_disabled(app, status, warning):
|
||||
|
||||
@pytest.mark.sphinx(buildername='html', testroot='smartquotes', freshenv=True,
|
||||
confoverrides={'smartquotes_action': 'q'})
|
||||
def test_smartquotes_action(app, status, warning):
|
||||
def test_smartquotes_action(app):
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -82,7 +82,7 @@ def test_smartquotes_action(app, status, warning):
|
||||
|
||||
@pytest.mark.sphinx(buildername='html', testroot='smartquotes', freshenv=True,
|
||||
confoverrides={'language': 'ja', 'smartquotes_excludes': {}})
|
||||
def test_smartquotes_excludes_language(app, status, warning):
|
||||
def test_smartquotes_excludes_language(app):
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -91,7 +91,7 @@ def test_smartquotes_excludes_language(app, status, warning):
|
||||
|
||||
@pytest.mark.sphinx(buildername='man', testroot='smartquotes', freshenv=True,
|
||||
confoverrides={'smartquotes_excludes': {}})
|
||||
def test_smartquotes_excludes_builders(app, status, warning):
|
||||
def test_smartquotes_excludes_builders(app):
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'projectnamenotset.1').read_text(encoding='utf8')
|
||||
|
@ -2,7 +2,7 @@ import pytest
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='theming')
|
||||
def test_theme_options(app, status, warning):
|
||||
def test_theme_options(app):
|
||||
app.build()
|
||||
|
||||
result = (app.outdir / '_static' / 'documentation_options.js').read_text(encoding='utf8')
|
||||
@ -18,7 +18,7 @@ def test_theme_options(app, status, warning):
|
||||
'html_theme_options.enable_search_shortcuts': False,
|
||||
},
|
||||
)
|
||||
def test_theme_options_with_override(app, status, warning):
|
||||
def test_theme_options_with_override(app):
|
||||
app.build()
|
||||
|
||||
result = (app.outdir / '_static' / 'documentation_options.js').read_text(encoding='utf8')
|
||||
|
@ -26,7 +26,7 @@ HERE = Path(__file__).resolve().parent
|
||||
testroot='theming',
|
||||
confoverrides={'html_theme': 'ziptheme', 'html_theme_options.testopt': 'foo'},
|
||||
)
|
||||
def test_theme_api(app, status, warning):
|
||||
def test_theme_api(app):
|
||||
themes = [
|
||||
'basic',
|
||||
'default',
|
||||
@ -98,19 +98,19 @@ def test_nonexistent_theme_settings(tmp_path):
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='double-inheriting-theme')
|
||||
def test_double_inheriting_theme(app, status, warning):
|
||||
def test_double_inheriting_theme(app):
|
||||
assert app.builder.theme.name == 'base_theme2'
|
||||
app.build() # => not raises TemplateNotFound
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='theming', confoverrides={'html_theme': 'child'})
|
||||
def test_nested_zipped_theme(app, status, warning):
|
||||
def test_nested_zipped_theme(app):
|
||||
assert app.builder.theme.name == 'child'
|
||||
app.build() # => not raises TemplateNotFound
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='theming', confoverrides={'html_theme': 'staticfiles'})
|
||||
def test_staticfiles(app, status, warning):
|
||||
def test_staticfiles(app):
|
||||
app.build()
|
||||
assert (app.outdir / '_static' / 'legacytmpl.html').exists()
|
||||
assert (app.outdir / '_static' / 'legacytmpl.html').read_text(encoding='utf8') == (
|
||||
@ -158,7 +158,7 @@ def test_dark_style(app, monkeypatch):
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='theming')
|
||||
def test_theme_sidebars(app, status, warning):
|
||||
def test_theme_sidebars(app):
|
||||
app.build()
|
||||
|
||||
# test-theme specifies globaltoc and searchbox as default sidebars
|
||||
|
@ -5,7 +5,7 @@ import pytest
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='toctree-glob')
|
||||
def test_relations(app, status, warning):
|
||||
def test_relations(app):
|
||||
app.build(force_all=True)
|
||||
assert app.builder.relations['index'] == [None, None, 'foo']
|
||||
assert app.builder.relations['foo'] == ['index', 'index', 'bar/index']
|
||||
@ -22,7 +22,7 @@ def test_relations(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('singlehtml', testroot='toctree-empty')
|
||||
def test_singlehtml_toctree(app, status, warning):
|
||||
def test_singlehtml_toctree(app):
|
||||
app.build(force_all=True)
|
||||
try:
|
||||
app.builder._get_local_toctree('index')
|
||||
@ -31,7 +31,7 @@ def test_singlehtml_toctree(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='toctree', srcdir="numbered-toctree")
|
||||
def test_numbered_toctree(app, status, warning):
|
||||
def test_numbered_toctree(app):
|
||||
# give argument to :numbered: option
|
||||
index = (app.srcdir / 'index.rst').read_text(encoding='utf8')
|
||||
index = re.sub(':numbered:.*', ':numbered: 1', index)
|
||||
|
@ -23,10 +23,10 @@ if TYPE_CHECKING:
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='transforms-post_transforms-missing-reference')
|
||||
def test_nitpicky_warning(app, warning):
|
||||
def test_nitpicky_warning(app):
|
||||
app.build()
|
||||
assert ('index.rst:4: WARNING: py:class reference target '
|
||||
'not found: io.StringIO' in warning.getvalue())
|
||||
'not found: io.StringIO' in app.warning.getvalue())
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert ('<p><code class="xref py py-class docutils literal notranslate"><span class="pre">'
|
||||
@ -35,7 +35,7 @@ def test_nitpicky_warning(app, warning):
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='transforms-post_transforms-missing-reference',
|
||||
freshenv=True)
|
||||
def test_missing_reference(app, warning):
|
||||
def test_missing_reference(app):
|
||||
def missing_reference(app_, env_, node_, contnode_):
|
||||
assert app_ is app
|
||||
assert env_ is app.env
|
||||
@ -44,10 +44,10 @@ def test_missing_reference(app, warning):
|
||||
|
||||
return nodes.inline('', 'missing-reference.StringIO')
|
||||
|
||||
warning.truncate(0)
|
||||
app.warning.truncate(0)
|
||||
app.connect('missing-reference', missing_reference)
|
||||
app.build()
|
||||
assert warning.getvalue() == ''
|
||||
assert app.warning.getvalue() == ''
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert '<p><span>missing-reference.StringIO</span></p>' in content
|
||||
@ -55,14 +55,14 @@ def test_missing_reference(app, warning):
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='domain-py-python_use_unqualified_type_names',
|
||||
freshenv=True)
|
||||
def test_missing_reference_conditional_pending_xref(app, warning):
|
||||
def test_missing_reference_conditional_pending_xref(app):
|
||||
def missing_reference(_app, _env, _node, contnode):
|
||||
return contnode
|
||||
|
||||
warning.truncate(0)
|
||||
app.warning.truncate(0)
|
||||
app.connect('missing-reference', missing_reference)
|
||||
app.build()
|
||||
assert warning.getvalue() == ''
|
||||
assert app.warning.getvalue() == ''
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert '<span class="n"><span class="pre">Age</span></span>' in content
|
||||
|
@ -2,7 +2,7 @@ import pytest
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='trim_doctest_flags')
|
||||
def test_trim_doctest_flags_html(app, status, warning):
|
||||
def test_trim_doctest_flags_html(app):
|
||||
app.build()
|
||||
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -17,7 +17,7 @@ def test_trim_doctest_flags_html(app, status, warning):
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='trim_doctest_flags',
|
||||
confoverrides={'trim_doctest_flags': False})
|
||||
def test_trim_doctest_flags_disabled(app, status, warning):
|
||||
def test_trim_doctest_flags_disabled(app):
|
||||
app.build()
|
||||
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -31,7 +31,7 @@ def test_trim_doctest_flags_disabled(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='trim_doctest_flags')
|
||||
def test_trim_doctest_flags_latex(app, status, warning):
|
||||
def test_trim_doctest_flags_latex(app):
|
||||
app.build()
|
||||
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
|
@ -21,29 +21,29 @@ def test_display_chunk():
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy')
|
||||
def test_status_iterator_length_0(app, status, warning):
|
||||
logging.setup(app, status, warning)
|
||||
def test_status_iterator_length_0(app):
|
||||
logging.setup(app, app.status, app.warning)
|
||||
|
||||
# test for status_iterator (length=0)
|
||||
status.seek(0)
|
||||
status.truncate(0)
|
||||
app.status.seek(0)
|
||||
app.status.truncate(0)
|
||||
yields = list(status_iterator(['hello', 'sphinx', 'world'], 'testing ... '))
|
||||
output = strip_colors(status.getvalue())
|
||||
output = strip_colors(app.status.getvalue())
|
||||
assert 'testing ... hello sphinx world \n' in output
|
||||
assert yields == ['hello', 'sphinx', 'world']
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy')
|
||||
def test_status_iterator_verbosity_0(app, status, warning, monkeypatch):
|
||||
def test_status_iterator_verbosity_0(app, monkeypatch):
|
||||
monkeypatch.setenv("FORCE_COLOR", "1")
|
||||
logging.setup(app, status, warning)
|
||||
logging.setup(app, app.status, app.warning)
|
||||
|
||||
# test for status_iterator (verbosity=0)
|
||||
status.seek(0)
|
||||
status.truncate(0)
|
||||
app.status.seek(0)
|
||||
app.status.truncate(0)
|
||||
yields = list(status_iterator(['hello', 'sphinx', 'world'], 'testing ... ',
|
||||
length=3, verbosity=0))
|
||||
output = strip_colors(status.getvalue())
|
||||
output = strip_colors(app.status.getvalue())
|
||||
assert 'testing ... [ 33%] hello\r' in output
|
||||
assert 'testing ... [ 67%] sphinx\r' in output
|
||||
assert 'testing ... [100%] world\r\n' in output
|
||||
@ -51,38 +51,38 @@ def test_status_iterator_verbosity_0(app, status, warning, monkeypatch):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy')
|
||||
def test_status_iterator_verbosity_1(app, status, warning, monkeypatch):
|
||||
def test_status_iterator_verbosity_1(app, monkeypatch):
|
||||
monkeypatch.setenv("FORCE_COLOR", "1")
|
||||
logging.setup(app, status, warning)
|
||||
logging.setup(app, app.status, app.warning)
|
||||
|
||||
# test for status_iterator (verbosity=1)
|
||||
status.seek(0)
|
||||
status.truncate(0)
|
||||
app.status.seek(0)
|
||||
app.status.truncate(0)
|
||||
yields = list(status_iterator(['hello', 'sphinx', 'world'], 'testing ... ',
|
||||
length=3, verbosity=1))
|
||||
output = strip_colors(status.getvalue())
|
||||
output = strip_colors(app.status.getvalue())
|
||||
assert 'testing ... [ 33%] hello\n' in output
|
||||
assert 'testing ... [ 67%] sphinx\n' in output
|
||||
assert 'testing ... [100%] world\n\n' in output
|
||||
assert yields == ['hello', 'sphinx', 'world']
|
||||
|
||||
|
||||
def test_progress_message(app, status, warning):
|
||||
logging.setup(app, status, warning)
|
||||
def test_progress_message(app):
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# standard case
|
||||
with progress_message('testing'):
|
||||
logger.info('blah ', nonl=True)
|
||||
|
||||
output = strip_colors(status.getvalue())
|
||||
output = strip_colors(app.status.getvalue())
|
||||
assert 'testing... blah done\n' in output
|
||||
|
||||
# skipping case
|
||||
with progress_message('testing'):
|
||||
raise SkipProgressMessage('Reason: %s', 'error') # NoQA: EM101
|
||||
|
||||
output = strip_colors(status.getvalue())
|
||||
output = strip_colors(app.status.getvalue())
|
||||
assert 'testing... skipped\nReason: error\n' in output
|
||||
|
||||
# error case
|
||||
@ -92,7 +92,7 @@ def test_progress_message(app, status, warning):
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
output = strip_colors(status.getvalue())
|
||||
output = strip_colors(app.status.getvalue())
|
||||
assert 'testing... failed\n' in output
|
||||
|
||||
# decorator
|
||||
@ -101,5 +101,5 @@ def test_progress_message(app, status, warning):
|
||||
logger.info('in func ', nonl=True)
|
||||
|
||||
func()
|
||||
output = strip_colors(status.getvalue())
|
||||
output = strip_colors(app.status.getvalue())
|
||||
assert 'testing... in func done\n' in output
|
||||
|
@ -56,7 +56,7 @@ def test_read_inventory_v2_not_having_version():
|
||||
('foo', '', '/util/foo.html#module-module1', 'Long Module desc')
|
||||
|
||||
|
||||
def test_ambiguous_definition_warning(warning, status):
|
||||
def test_ambiguous_definition_warning(app):
|
||||
f = BytesIO(INVENTORY_V2_AMBIGUOUS_TERMS)
|
||||
InventoryFile.load(f, '/util', posixpath.join)
|
||||
|
||||
@ -68,10 +68,10 @@ def test_ambiguous_definition_warning(warning, status):
|
||||
_multiple_defs_notice_for('std:term:a'),
|
||||
_multiple_defs_notice_for('std:term:b'),
|
||||
)
|
||||
assert mult_defs_a not in warning.getvalue().lower()
|
||||
assert mult_defs_a not in status.getvalue().lower()
|
||||
assert mult_defs_b not in warning.getvalue().lower()
|
||||
assert mult_defs_b in status.getvalue().lower()
|
||||
assert mult_defs_a not in app.warning.getvalue().lower()
|
||||
assert mult_defs_a not in app.status.getvalue().lower()
|
||||
assert mult_defs_b not in app.warning.getvalue().lower()
|
||||
assert mult_defs_b in app.status.getvalue().lower()
|
||||
|
||||
|
||||
def _write_appconfig(dir: Path, language: str, prefix: str | None = None) -> Path:
|
||||
|
@ -14,9 +14,9 @@ from sphinx.util.logging import is_suppressed_warning, prefixed_warnings
|
||||
from sphinx.util.parallel import ParallelTasks
|
||||
|
||||
|
||||
def test_info_and_warning(app, status, warning):
|
||||
def test_info_and_warning(app):
|
||||
app.verbosity = 2
|
||||
logging.setup(app, status, warning)
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
logger.debug('message1')
|
||||
@ -25,91 +25,91 @@ def test_info_and_warning(app, status, warning):
|
||||
logger.critical('message4')
|
||||
logger.error('message5')
|
||||
|
||||
assert 'message1' in status.getvalue()
|
||||
assert 'message2' in status.getvalue()
|
||||
assert 'message3' not in status.getvalue()
|
||||
assert 'message4' not in status.getvalue()
|
||||
assert 'message5' not in status.getvalue()
|
||||
assert 'message1' in app.status.getvalue()
|
||||
assert 'message2' in app.status.getvalue()
|
||||
assert 'message3' not in app.status.getvalue()
|
||||
assert 'message4' not in app.status.getvalue()
|
||||
assert 'message5' not in app.status.getvalue()
|
||||
|
||||
assert 'message1' not in warning.getvalue()
|
||||
assert 'message2' not in warning.getvalue()
|
||||
assert 'WARNING: message3' in warning.getvalue()
|
||||
assert 'CRITICAL: message4' in warning.getvalue()
|
||||
assert 'ERROR: message5' in warning.getvalue()
|
||||
assert 'message1' not in app.warning.getvalue()
|
||||
assert 'message2' not in app.warning.getvalue()
|
||||
assert 'WARNING: message3' in app.warning.getvalue()
|
||||
assert 'CRITICAL: message4' in app.warning.getvalue()
|
||||
assert 'ERROR: message5' in app.warning.getvalue()
|
||||
|
||||
|
||||
def test_Exception(app, status, warning):
|
||||
logging.setup(app, status, warning)
|
||||
def test_Exception(app):
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
logger.info(Exception)
|
||||
assert "<class 'Exception'>" in status.getvalue()
|
||||
assert "<class 'Exception'>" in app.status.getvalue()
|
||||
|
||||
|
||||
def test_verbosity_filter(app, status, warning):
|
||||
def test_verbosity_filter(app):
|
||||
# verbosity = 0: INFO
|
||||
app.verbosity = 0
|
||||
logging.setup(app, status, warning)
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
logger.info('message1')
|
||||
logger.verbose('message2')
|
||||
logger.debug('message3')
|
||||
|
||||
assert 'message1' in status.getvalue()
|
||||
assert 'message2' not in status.getvalue()
|
||||
assert 'message3' not in status.getvalue()
|
||||
assert 'message4' not in status.getvalue()
|
||||
assert 'message1' in app.status.getvalue()
|
||||
assert 'message2' not in app.status.getvalue()
|
||||
assert 'message3' not in app.status.getvalue()
|
||||
assert 'message4' not in app.status.getvalue()
|
||||
|
||||
# verbosity = 1: VERBOSE
|
||||
app.verbosity = 1
|
||||
logging.setup(app, status, warning)
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
logger.info('message1')
|
||||
logger.verbose('message2')
|
||||
logger.debug('message3')
|
||||
|
||||
assert 'message1' in status.getvalue()
|
||||
assert 'message2' in status.getvalue()
|
||||
assert 'message3' not in status.getvalue()
|
||||
assert 'message4' not in status.getvalue()
|
||||
assert 'message1' in app.status.getvalue()
|
||||
assert 'message2' in app.status.getvalue()
|
||||
assert 'message3' not in app.status.getvalue()
|
||||
assert 'message4' not in app.status.getvalue()
|
||||
|
||||
# verbosity = 2: DEBUG
|
||||
app.verbosity = 2
|
||||
logging.setup(app, status, warning)
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
logger.info('message1')
|
||||
logger.verbose('message2')
|
||||
logger.debug('message3')
|
||||
|
||||
assert 'message1' in status.getvalue()
|
||||
assert 'message2' in status.getvalue()
|
||||
assert 'message3' in status.getvalue()
|
||||
assert 'message4' not in status.getvalue()
|
||||
assert 'message1' in app.status.getvalue()
|
||||
assert 'message2' in app.status.getvalue()
|
||||
assert 'message3' in app.status.getvalue()
|
||||
assert 'message4' not in app.status.getvalue()
|
||||
|
||||
|
||||
def test_nonl_info_log(app, status, warning):
|
||||
logging.setup(app, status, warning)
|
||||
def test_nonl_info_log(app):
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
logger.info('message1', nonl=True)
|
||||
logger.info('message2')
|
||||
logger.info('message3')
|
||||
|
||||
assert 'message1message2\nmessage3' in status.getvalue()
|
||||
assert 'message1message2\nmessage3' in app.status.getvalue()
|
||||
|
||||
|
||||
def test_once_warning_log(app, status, warning):
|
||||
logging.setup(app, status, warning)
|
||||
def test_once_warning_log(app):
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
logger.warning('message: %d', 1, once=True)
|
||||
logger.warning('message: %d', 1, once=True)
|
||||
logger.warning('message: %d', 2, once=True)
|
||||
|
||||
assert 'WARNING: message: 1\nWARNING: message: 2\n' in strip_colors(warning.getvalue())
|
||||
assert 'WARNING: message: 1\nWARNING: message: 2\n' in strip_colors(app.warning.getvalue())
|
||||
|
||||
|
||||
def test_is_suppressed_warning():
|
||||
@ -126,51 +126,51 @@ def test_is_suppressed_warning():
|
||||
assert is_suppressed_warning("rest", "duplicated_labels", suppress_warnings) is True
|
||||
|
||||
|
||||
def test_suppress_warnings(app, status, warning):
|
||||
logging.setup(app, status, warning)
|
||||
def test_suppress_warnings(app):
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
app._warncount = 0 # force reset
|
||||
|
||||
app.config.suppress_warnings = []
|
||||
warning.truncate(0)
|
||||
app.warning.truncate(0)
|
||||
logger.warning('message0', type='test')
|
||||
logger.warning('message1', type='test', subtype='logging')
|
||||
logger.warning('message2', type='test', subtype='crash')
|
||||
logger.warning('message3', type='actual', subtype='logging')
|
||||
assert 'message0' in warning.getvalue()
|
||||
assert 'message1' in warning.getvalue()
|
||||
assert 'message2' in warning.getvalue()
|
||||
assert 'message3' in warning.getvalue()
|
||||
assert 'message0' in app.warning.getvalue()
|
||||
assert 'message1' in app.warning.getvalue()
|
||||
assert 'message2' in app.warning.getvalue()
|
||||
assert 'message3' in app.warning.getvalue()
|
||||
assert app._warncount == 4
|
||||
|
||||
app.config.suppress_warnings = ['test']
|
||||
warning.truncate(0)
|
||||
app.warning.truncate(0)
|
||||
logger.warning('message0', type='test')
|
||||
logger.warning('message1', type='test', subtype='logging')
|
||||
logger.warning('message2', type='test', subtype='crash')
|
||||
logger.warning('message3', type='actual', subtype='logging')
|
||||
assert 'message0' not in warning.getvalue()
|
||||
assert 'message1' not in warning.getvalue()
|
||||
assert 'message2' not in warning.getvalue()
|
||||
assert 'message3' in warning.getvalue()
|
||||
assert 'message0' not in app.warning.getvalue()
|
||||
assert 'message1' not in app.warning.getvalue()
|
||||
assert 'message2' not in app.warning.getvalue()
|
||||
assert 'message3' in app.warning.getvalue()
|
||||
assert app._warncount == 5
|
||||
|
||||
app.config.suppress_warnings = ['test.logging']
|
||||
warning.truncate(0)
|
||||
app.warning.truncate(0)
|
||||
logger.warning('message0', type='test')
|
||||
logger.warning('message1', type='test', subtype='logging')
|
||||
logger.warning('message2', type='test', subtype='crash')
|
||||
logger.warning('message3', type='actual', subtype='logging')
|
||||
assert 'message0' in warning.getvalue()
|
||||
assert 'message1' not in warning.getvalue()
|
||||
assert 'message2' in warning.getvalue()
|
||||
assert 'message3' in warning.getvalue()
|
||||
assert 'message0' in app.warning.getvalue()
|
||||
assert 'message1' not in app.warning.getvalue()
|
||||
assert 'message2' in app.warning.getvalue()
|
||||
assert 'message3' in app.warning.getvalue()
|
||||
assert app._warncount == 8
|
||||
|
||||
|
||||
def test_warningiserror(app, status, warning):
|
||||
logging.setup(app, status, warning)
|
||||
def test_warningiserror(app):
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# if False, warning is not error
|
||||
@ -187,84 +187,84 @@ def test_warningiserror(app, status, warning):
|
||||
logger.warning('%s')
|
||||
|
||||
|
||||
def test_info_location(app, status, warning):
|
||||
logging.setup(app, status, warning)
|
||||
def test_info_location(app):
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
logger.info('message1', location='index')
|
||||
assert 'index.txt: message1' in status.getvalue()
|
||||
assert 'index.txt: message1' in app.status.getvalue()
|
||||
|
||||
logger.info('message2', location=('index', 10))
|
||||
assert 'index.txt:10: message2' in status.getvalue()
|
||||
assert 'index.txt:10: message2' in app.status.getvalue()
|
||||
|
||||
logger.info('message3', location=None)
|
||||
assert '\nmessage3' in status.getvalue()
|
||||
assert '\nmessage3' in app.status.getvalue()
|
||||
|
||||
node = nodes.Node()
|
||||
node.source, node.line = ('index.txt', 10)
|
||||
logger.info('message4', location=node)
|
||||
assert 'index.txt:10: message4' in status.getvalue()
|
||||
assert 'index.txt:10: message4' in app.status.getvalue()
|
||||
|
||||
node.source, node.line = ('index.txt', None)
|
||||
logger.info('message5', location=node)
|
||||
assert 'index.txt:: message5' in status.getvalue()
|
||||
assert 'index.txt:: message5' in app.status.getvalue()
|
||||
|
||||
node.source, node.line = (None, 10)
|
||||
logger.info('message6', location=node)
|
||||
assert '<unknown>:10: message6' in status.getvalue()
|
||||
assert '<unknown>:10: message6' in app.status.getvalue()
|
||||
|
||||
node.source, node.line = (None, None)
|
||||
logger.info('message7', location=node)
|
||||
assert '\nmessage7' in status.getvalue()
|
||||
assert '\nmessage7' in app.status.getvalue()
|
||||
|
||||
|
||||
def test_warning_location(app, status, warning):
|
||||
logging.setup(app, status, warning)
|
||||
def test_warning_location(app):
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
logger.warning('message1', location='index')
|
||||
assert 'index.txt: WARNING: message1' in warning.getvalue()
|
||||
assert 'index.txt: WARNING: message1' in app.warning.getvalue()
|
||||
|
||||
logger.warning('message2', location=('index', 10))
|
||||
assert 'index.txt:10: WARNING: message2' in warning.getvalue()
|
||||
assert 'index.txt:10: WARNING: message2' in app.warning.getvalue()
|
||||
|
||||
logger.warning('message3', location=None)
|
||||
assert colorize('red', 'WARNING: message3') in warning.getvalue()
|
||||
assert colorize('red', 'WARNING: message3') in app.warning.getvalue()
|
||||
|
||||
node = nodes.Node()
|
||||
node.source, node.line = ('index.txt', 10)
|
||||
logger.warning('message4', location=node)
|
||||
assert 'index.txt:10: WARNING: message4' in warning.getvalue()
|
||||
assert 'index.txt:10: WARNING: message4' in app.warning.getvalue()
|
||||
|
||||
node.source, node.line = ('index.txt', None)
|
||||
logger.warning('message5', location=node)
|
||||
assert 'index.txt:: WARNING: message5' in warning.getvalue()
|
||||
assert 'index.txt:: WARNING: message5' in app.warning.getvalue()
|
||||
|
||||
node.source, node.line = (None, 10)
|
||||
logger.warning('message6', location=node)
|
||||
assert '<unknown>:10: WARNING: message6' in warning.getvalue()
|
||||
assert '<unknown>:10: WARNING: message6' in app.warning.getvalue()
|
||||
|
||||
node.source, node.line = (None, None)
|
||||
logger.warning('message7', location=node)
|
||||
assert colorize('red', 'WARNING: message7') in warning.getvalue()
|
||||
assert colorize('red', 'WARNING: message7') in app.warning.getvalue()
|
||||
|
||||
|
||||
def test_suppress_logging(app, status, warning):
|
||||
logging.setup(app, status, warning)
|
||||
def test_suppress_logging(app):
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
logger.warning('message1')
|
||||
with logging.suppress_logging():
|
||||
logger.warning('message2')
|
||||
assert 'WARNING: message1' in warning.getvalue()
|
||||
assert 'WARNING: message2' not in warning.getvalue()
|
||||
assert 'WARNING: message1' in app.warning.getvalue()
|
||||
assert 'WARNING: message2' not in app.warning.getvalue()
|
||||
|
||||
assert 'WARNING: message1' in warning.getvalue()
|
||||
assert 'WARNING: message2' not in warning.getvalue()
|
||||
assert 'WARNING: message1' in app.warning.getvalue()
|
||||
assert 'WARNING: message2' not in app.warning.getvalue()
|
||||
|
||||
|
||||
def test_pending_warnings(app, status, warning):
|
||||
logging.setup(app, status, warning)
|
||||
def test_pending_warnings(app):
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
logger.warning('message1')
|
||||
@ -272,17 +272,17 @@ def test_pending_warnings(app, status, warning):
|
||||
# not logged yet (buffered) in here
|
||||
logger.warning('message2')
|
||||
logger.warning('message3')
|
||||
assert 'WARNING: message1' in warning.getvalue()
|
||||
assert 'WARNING: message2' not in warning.getvalue()
|
||||
assert 'WARNING: message3' not in warning.getvalue()
|
||||
assert 'WARNING: message1' in app.warning.getvalue()
|
||||
assert 'WARNING: message2' not in app.warning.getvalue()
|
||||
assert 'WARNING: message3' not in app.warning.getvalue()
|
||||
|
||||
# actually logged as ordered
|
||||
assert 'WARNING: message2\nWARNING: message3' in strip_colors(warning.getvalue())
|
||||
assert 'WARNING: message2\nWARNING: message3' in strip_colors(app.warning.getvalue())
|
||||
|
||||
|
||||
def test_colored_logs(app, status, warning):
|
||||
def test_colored_logs(app):
|
||||
app.verbosity = 2
|
||||
logging.setup(app, status, warning)
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# default colors
|
||||
@ -293,24 +293,24 @@ def test_colored_logs(app, status, warning):
|
||||
logger.critical('message5')
|
||||
logger.error('message6')
|
||||
|
||||
assert colorize('darkgray', 'message1') in status.getvalue()
|
||||
assert 'message2\n' in status.getvalue() # not colored
|
||||
assert 'message3\n' in status.getvalue() # not colored
|
||||
assert colorize('red', 'WARNING: message4') in warning.getvalue()
|
||||
assert 'CRITICAL: message5\n' in warning.getvalue() # not colored
|
||||
assert colorize('darkred', 'ERROR: message6') in warning.getvalue()
|
||||
assert colorize('darkgray', 'message1') in app.status.getvalue()
|
||||
assert 'message2\n' in app.status.getvalue() # not colored
|
||||
assert 'message3\n' in app.status.getvalue() # not colored
|
||||
assert colorize('red', 'WARNING: message4') in app.warning.getvalue()
|
||||
assert 'CRITICAL: message5\n' in app.warning.getvalue() # not colored
|
||||
assert colorize('darkred', 'ERROR: message6') in app.warning.getvalue()
|
||||
|
||||
# color specification
|
||||
logger.debug('message7', color='white')
|
||||
logger.info('message8', color='red')
|
||||
assert colorize('white', 'message7') in status.getvalue()
|
||||
assert colorize('red', 'message8') in status.getvalue()
|
||||
assert colorize('white', 'message7') in app.status.getvalue()
|
||||
assert colorize('red', 'message8') in app.status.getvalue()
|
||||
|
||||
|
||||
@pytest.mark.xfail(os.name != 'posix',
|
||||
reason="Parallel mode does not work on Windows")
|
||||
def test_logging_in_ParallelTasks(app, status, warning):
|
||||
logging.setup(app, status, warning)
|
||||
def test_logging_in_ParallelTasks(app):
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
def child_process():
|
||||
@ -320,27 +320,27 @@ def test_logging_in_ParallelTasks(app, status, warning):
|
||||
tasks = ParallelTasks(1)
|
||||
tasks.add_task(child_process)
|
||||
tasks.join()
|
||||
assert 'message1' in status.getvalue()
|
||||
assert 'index.txt: WARNING: message2' in warning.getvalue()
|
||||
assert 'message1' in app.status.getvalue()
|
||||
assert 'index.txt: WARNING: message2' in app.warning.getvalue()
|
||||
|
||||
|
||||
def test_output_with_unencodable_char(app, status, warning):
|
||||
def test_output_with_unencodable_char(app):
|
||||
class StreamWriter(codecs.StreamWriter):
|
||||
def write(self, object):
|
||||
self.stream.write(object.encode('cp1252').decode('cp1252'))
|
||||
|
||||
logging.setup(app, StreamWriter(status), warning)
|
||||
logging.setup(app, StreamWriter(app.status), app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# info with UnicodeEncodeError
|
||||
status.truncate(0)
|
||||
status.seek(0)
|
||||
app.status.truncate(0)
|
||||
app.status.seek(0)
|
||||
logger.info("unicode \u206d...")
|
||||
assert status.getvalue() == "unicode ?...\n"
|
||||
assert app.status.getvalue() == "unicode ?...\n"
|
||||
|
||||
|
||||
def test_skip_warningiserror(app, status, warning):
|
||||
logging.setup(app, status, warning)
|
||||
def test_skip_warningiserror(app):
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
app.warningiserror = True
|
||||
@ -363,8 +363,8 @@ def test_skip_warningiserror(app, status, warning):
|
||||
logger.warning('message')
|
||||
|
||||
|
||||
def test_prefixed_warnings(app, status, warning):
|
||||
logging.setup(app, status, warning)
|
||||
def test_prefixed_warnings(app):
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
logger.warning('message1')
|
||||
@ -375,11 +375,11 @@ def test_prefixed_warnings(app, status, warning):
|
||||
logger.warning('message4')
|
||||
logger.warning('message5')
|
||||
|
||||
assert 'WARNING: message1' in warning.getvalue()
|
||||
assert 'WARNING: PREFIX: message2' in warning.getvalue()
|
||||
assert 'WARNING: Another PREFIX: message3' in warning.getvalue()
|
||||
assert 'WARNING: PREFIX: message4' in warning.getvalue()
|
||||
assert 'WARNING: message5' in warning.getvalue()
|
||||
assert 'WARNING: message1' in app.warning.getvalue()
|
||||
assert 'WARNING: PREFIX: message2' in app.warning.getvalue()
|
||||
assert 'WARNING: Another PREFIX: message3' in app.warning.getvalue()
|
||||
assert 'WARNING: PREFIX: message4' in app.warning.getvalue()
|
||||
assert 'WARNING: message5' in app.warning.getvalue()
|
||||
|
||||
|
||||
def test_get_node_location_abspath():
|
||||
@ -398,14 +398,14 @@ def test_get_node_location_abspath():
|
||||
|
||||
|
||||
@pytest.mark.sphinx(confoverrides={'show_warning_types': True})
|
||||
def test_show_warning_types(app, status, warning):
|
||||
logging.setup(app, status, warning)
|
||||
def test_show_warning_types(app):
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.warning('message2')
|
||||
logger.warning('message3', type='test')
|
||||
logger.warning('message4', type='test', subtype='logging')
|
||||
|
||||
warnings = strip_colors(warning.getvalue()).splitlines()
|
||||
warnings = strip_colors(app.warning.getvalue()).splitlines()
|
||||
|
||||
assert warnings == [
|
||||
'WARNING: message2',
|
||||
|
@ -14,7 +14,7 @@ def _setup_module(rootdir):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html')
|
||||
def test_html_translator(app, status, warning):
|
||||
def test_html_translator(app):
|
||||
# no set_translator()
|
||||
translator_class = app.builder.get_translator_class()
|
||||
assert translator_class
|
||||
@ -22,7 +22,7 @@ def test_html_translator(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='api-set-translator')
|
||||
def test_html_with_set_translator_for_html_(app, status, warning):
|
||||
def test_html_with_set_translator_for_html_(app):
|
||||
# use set_translator()
|
||||
translator_class = app.builder.get_translator_class()
|
||||
assert translator_class
|
||||
@ -30,63 +30,63 @@ def test_html_with_set_translator_for_html_(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('singlehtml', testroot='api-set-translator')
|
||||
def test_singlehtml_set_translator_for_singlehtml(app, status, warning):
|
||||
def test_singlehtml_set_translator_for_singlehtml(app):
|
||||
translator_class = app.builder.get_translator_class()
|
||||
assert translator_class
|
||||
assert translator_class.__name__ == 'ConfSingleHTMLTranslator'
|
||||
|
||||
|
||||
@pytest.mark.sphinx('pickle', testroot='api-set-translator')
|
||||
def test_pickle_set_translator_for_pickle(app, status, warning):
|
||||
def test_pickle_set_translator_for_pickle(app):
|
||||
translator_class = app.builder.get_translator_class()
|
||||
assert translator_class
|
||||
assert translator_class.__name__ == 'ConfPickleTranslator'
|
||||
|
||||
|
||||
@pytest.mark.sphinx('json', testroot='api-set-translator')
|
||||
def test_json_set_translator_for_json(app, status, warning):
|
||||
def test_json_set_translator_for_json(app):
|
||||
translator_class = app.builder.get_translator_class()
|
||||
assert translator_class
|
||||
assert translator_class.__name__ == 'ConfJsonTranslator'
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='api-set-translator')
|
||||
def test_html_with_set_translator_for_latex(app, status, warning):
|
||||
def test_html_with_set_translator_for_latex(app):
|
||||
translator_class = app.builder.get_translator_class()
|
||||
assert translator_class
|
||||
assert translator_class.__name__ == 'ConfLaTeXTranslator'
|
||||
|
||||
|
||||
@pytest.mark.sphinx('man', testroot='api-set-translator')
|
||||
def test_html_with_set_translator_for_man(app, status, warning):
|
||||
def test_html_with_set_translator_for_man(app):
|
||||
translator_class = app.builder.get_translator_class()
|
||||
assert translator_class
|
||||
assert translator_class.__name__ == 'ConfManualPageTranslator'
|
||||
|
||||
|
||||
@pytest.mark.sphinx('texinfo', testroot='api-set-translator')
|
||||
def test_html_with_set_translator_for_texinfo(app, status, warning):
|
||||
def test_html_with_set_translator_for_texinfo(app):
|
||||
translator_class = app.builder.get_translator_class()
|
||||
assert translator_class
|
||||
assert translator_class.__name__ == 'ConfTexinfoTranslator'
|
||||
|
||||
|
||||
@pytest.mark.sphinx('text', testroot='api-set-translator')
|
||||
def test_html_with_set_translator_for_text(app, status, warning):
|
||||
def test_html_with_set_translator_for_text(app):
|
||||
translator_class = app.builder.get_translator_class()
|
||||
assert translator_class
|
||||
assert translator_class.__name__ == 'ConfTextTranslator'
|
||||
|
||||
|
||||
@pytest.mark.sphinx('xml', testroot='api-set-translator')
|
||||
def test_html_with_set_translator_for_xml(app, status, warning):
|
||||
def test_html_with_set_translator_for_xml(app):
|
||||
translator_class = app.builder.get_translator_class()
|
||||
assert translator_class
|
||||
assert translator_class.__name__ == 'ConfXMLTranslator'
|
||||
|
||||
|
||||
@pytest.mark.sphinx('pseudoxml', testroot='api-set-translator')
|
||||
def test_html_with_set_translator_for_pseudoxml(app, status, warning):
|
||||
def test_html_with_set_translator_for_pseudoxml(app):
|
||||
translator_class = app.builder.get_translator_class()
|
||||
assert translator_class
|
||||
assert translator_class.__name__ == 'ConfPseudoXMLTranslator'
|
||||
|
@ -8,7 +8,7 @@ from sphinx.util.docutils import patch_docutils
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='docutilsconf', freshenv=True)
|
||||
def test_html_with_default_docutilsconf(app, status, warning):
|
||||
def test_html_with_default_docutilsconf(app):
|
||||
with patch_docutils(app.confdir):
|
||||
app.build()
|
||||
|
||||
@ -20,7 +20,7 @@ def test_html_with_default_docutilsconf(app, status, warning):
|
||||
@pytest.mark.sphinx('dummy', testroot='docutilsconf', freshenv=True,
|
||||
docutils_conf=('[restructuredtext parser]\n'
|
||||
'trim_footnote_reference_space: true\n'))
|
||||
def test_html_with_docutilsconf(app, status, warning):
|
||||
def test_html_with_docutilsconf(app):
|
||||
with patch_docutils(app.confdir):
|
||||
app.build()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user