mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Add annotations to several single-argument ('app') test functions
This commit is contained in:
parent
a980fbcafa
commit
f1fbbfcbb7
@ -49,7 +49,7 @@ def test_instantiation(
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root')
|
||||
def test_events(app):
|
||||
def test_events(app: SphinxTestApp) -> None:
|
||||
def empty():
|
||||
pass
|
||||
|
||||
@ -76,27 +76,27 @@ def test_events(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root')
|
||||
def test_emit_with_nonascii_name_node(app):
|
||||
def test_emit_with_nonascii_name_node(app: SphinxTestApp) -> None:
|
||||
node = nodes.section(names=['\u65e5\u672c\u8a9e'])
|
||||
app.emit('my_event', node)
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root')
|
||||
def test_extensions(app):
|
||||
def test_extensions(app: SphinxTestApp) -> None:
|
||||
app.setup_extension('shutil')
|
||||
warning = strip_escape_sequences(app.warning.getvalue())
|
||||
assert "extension 'shutil' has no setup() function" in warning
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root')
|
||||
def test_extension_in_blacklist(app):
|
||||
def test_extension_in_blacklist(app: SphinxTestApp) -> None:
|
||||
app.setup_extension('sphinxjp.themecore')
|
||||
msg = strip_escape_sequences(app.warning.getvalue())
|
||||
assert msg.startswith("WARNING: the extension 'sphinxjp.themecore' was")
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='add_source_parser')
|
||||
def test_add_source_parser(app):
|
||||
def test_add_source_parser(app: SphinxTestApp) -> None:
|
||||
assert set(app.config.source_suffix) == {'.rst', '.test'}
|
||||
|
||||
# .rst; only in :confval:`source_suffix`
|
||||
@ -110,7 +110,7 @@ def test_add_source_parser(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='extensions')
|
||||
def test_add_is_parallel_allowed(app):
|
||||
def test_add_is_parallel_allowed(app: SphinxTestApp) -> None:
|
||||
logging.setup(app, app.status, app.warning)
|
||||
|
||||
assert app.is_parallel_allowed('read') is True
|
||||
@ -155,14 +155,14 @@ def test_add_is_parallel_allowed(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='root')
|
||||
def test_build_specific(app):
|
||||
app.builder.build = Mock()
|
||||
def test_build_specific(app: SphinxTestApp) -> None:
|
||||
app.builder.build = Mock() # type: ignore[method-assign,misc]
|
||||
filenames = [
|
||||
app.srcdir / 'index.txt', # normal
|
||||
app.srcdir / 'images', # without suffix
|
||||
app.srcdir / 'notfound.txt', # not found
|
||||
app.srcdir / 'img.png', # unknown suffix
|
||||
'/index.txt', # external file
|
||||
Path('/index.txt'), # external file
|
||||
app.srcdir / 'subdir', # directory
|
||||
app.srcdir / 'subdir/includes.txt', # file on subdir
|
||||
app.srcdir / 'subdir/../subdir/excluded.txt', # not normalized
|
||||
|
@ -2,11 +2,16 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
from docutils import nodes
|
||||
|
||||
from sphinx.errors import SphinxError
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
def test_root_doc_not_found(tmp_path, make_app):
|
||||
(tmp_path / 'conf.py').touch()
|
||||
@ -18,7 +23,7 @@ def test_root_doc_not_found(tmp_path, make_app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('text', testroot='circular')
|
||||
def test_circular_toctree(app):
|
||||
def test_circular_toctree(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
warnings = app.warning.getvalue()
|
||||
assert (
|
||||
@ -30,7 +35,7 @@ def test_circular_toctree(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('text', testroot='numbered-circular')
|
||||
def test_numbered_circular_toctree(app):
|
||||
def test_numbered_circular_toctree(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
warnings = app.warning.getvalue()
|
||||
assert (
|
||||
@ -42,7 +47,7 @@ def test_numbered_circular_toctree(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('text', testroot='toctree-multiple-parents')
|
||||
def test_multiple_parents_toctree(app):
|
||||
def test_multiple_parents_toctree(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
assert (
|
||||
"document is referenced in multiple toctrees: ['bravo', 'delta'], selecting: delta <- charlie"
|
||||
|
@ -12,6 +12,8 @@ from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Callable
|
||||
from pathlib import Path
|
||||
|
@ -2,11 +2,16 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('changes', testroot='changes')
|
||||
def test_build(app):
|
||||
def test_build(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
# TODO: Use better checking of html content
|
||||
@ -34,7 +39,7 @@ def test_build(app):
|
||||
srcdir='changes-none',
|
||||
confoverrides={'version': '0.7', 'release': '0.7b1'},
|
||||
)
|
||||
def test_no_changes(app):
|
||||
def test_no_changes(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
assert 'no changes in version 0.7.' in app.status.getvalue()
|
||||
|
@ -3,14 +3,18 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import posixpath
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
from sphinx.util.inventory import InventoryFile, _InventoryItem
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dirhtml', testroot='builder-dirhtml')
|
||||
def test_dirhtml(app):
|
||||
def test_dirhtml(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
assert (app.outdir / 'index.html').exists()
|
||||
|
@ -12,6 +12,7 @@ from typing import TYPE_CHECKING
|
||||
import pytest
|
||||
|
||||
from sphinx.builders.epub3 import _XML_NAME_PATTERN
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Iterator
|
||||
|
@ -13,6 +13,7 @@ from typing import TYPE_CHECKING
|
||||
import pytest
|
||||
|
||||
from sphinx.builders.gettext import Catalog, MsgOrigin
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
@ -10,7 +10,11 @@ from typing import TYPE_CHECKING
|
||||
import pytest
|
||||
|
||||
from sphinx._cli.util.errors import strip_escape_sequences
|
||||
from sphinx.builders.html import validate_html_extra_path, validate_html_static_path
|
||||
from sphinx.builders.html import (
|
||||
StandaloneHTMLBuilder,
|
||||
validate_html_extra_path,
|
||||
validate_html_static_path,
|
||||
)
|
||||
from sphinx.errors import ConfigError
|
||||
from sphinx.testing.util import etree_parse
|
||||
from sphinx.util.inventory import InventoryFile, _InventoryItem
|
||||
@ -21,6 +25,8 @@ from tests.test_builders.xpath_util import check_xpath
|
||||
if TYPE_CHECKING:
|
||||
from typing import Any
|
||||
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
def test_html_sidebars_error(make_app, tmp_path):
|
||||
(tmp_path / 'conf.py').touch()
|
||||
@ -136,13 +142,14 @@ def test_docutils_output(app, cached_etree_parse, fname, path, check):
|
||||
testroot='root',
|
||||
parallel=2,
|
||||
)
|
||||
def test_html_parallel(app):
|
||||
def test_html_parallel(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='build-html-translator')
|
||||
def test_html_translator(app):
|
||||
def test_html_translator(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
assert isinstance(app.builder, StandaloneHTMLBuilder) # type-checking
|
||||
assert app.builder.docwriter.visitor.depart_with_node == 10
|
||||
|
||||
|
||||
@ -176,7 +183,7 @@ def test_enumerable_node(app, cached_etree_parse, expect):
|
||||
testroot='basic',
|
||||
confoverrides={'html_copy_source': False},
|
||||
)
|
||||
def test_html_copy_source(app):
|
||||
def test_html_copy_source(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
assert not (app.outdir / '_sources' / 'index.rst.txt').exists()
|
||||
|
||||
@ -186,7 +193,7 @@ def test_html_copy_source(app):
|
||||
testroot='basic',
|
||||
confoverrides={'html_sourcelink_suffix': '.txt'},
|
||||
)
|
||||
def test_html_sourcelink_suffix(app):
|
||||
def test_html_sourcelink_suffix(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
assert (app.outdir / '_sources' / 'index.rst.txt').exists()
|
||||
|
||||
@ -196,7 +203,7 @@ def test_html_sourcelink_suffix(app):
|
||||
testroot='basic',
|
||||
confoverrides={'html_sourcelink_suffix': '.rst'},
|
||||
)
|
||||
def test_html_sourcelink_suffix_same(app):
|
||||
def test_html_sourcelink_suffix_same(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
assert (app.outdir / '_sources' / 'index.rst').exists()
|
||||
|
||||
@ -206,13 +213,13 @@ def test_html_sourcelink_suffix_same(app):
|
||||
testroot='basic',
|
||||
confoverrides={'html_sourcelink_suffix': ''},
|
||||
)
|
||||
def test_html_sourcelink_suffix_empty(app):
|
||||
def test_html_sourcelink_suffix_empty(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
assert (app.outdir / '_sources' / 'index.rst').exists()
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='html_entity')
|
||||
def test_html_entity(app):
|
||||
def test_html_entity(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
valid_entities = {'amp', 'lt', 'gt', 'quot', 'apos'}
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -221,7 +228,7 @@ def test_html_entity(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='basic')
|
||||
def test_html_inventory(app):
|
||||
def test_html_inventory(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
with app.outdir.joinpath('objects.inv').open('rb') as f:
|
||||
@ -273,7 +280,7 @@ def test_html_inventory(app):
|
||||
testroot='images',
|
||||
confoverrides={'html_sourcelink_suffix': ''},
|
||||
)
|
||||
def test_html_anchor_for_figure(app):
|
||||
def test_html_anchor_for_figure(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert (
|
||||
@ -283,7 +290,7 @@ def test_html_anchor_for_figure(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='directives-raw')
|
||||
def test_html_raw_directive(app):
|
||||
def test_html_raw_directive(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
|
||||
@ -350,7 +357,7 @@ def test_alternate_stylesheets(app, cached_etree_parse, expect):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='html_style')
|
||||
def test_html_style(app):
|
||||
def test_html_style(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert (
|
||||
@ -374,7 +381,7 @@ def test_html_style(app):
|
||||
}
|
||||
},
|
||||
)
|
||||
def test_html_sidebar(app):
|
||||
def test_html_sidebar(app: SphinxTestApp) -> None:
|
||||
ctx: dict[str, Any] = {}
|
||||
|
||||
# default for alabaster
|
||||
@ -391,6 +398,7 @@ def test_html_sidebar(app):
|
||||
# sourcelink.html
|
||||
assert '<h3>This Page</h3>' in result
|
||||
|
||||
assert isinstance(app.builder, StandaloneHTMLBuilder) # type-checking
|
||||
app.builder.add_sidebars('index', ctx)
|
||||
assert ctx['sidebars'] == [
|
||||
'localtoc.html',
|
||||
@ -413,6 +421,7 @@ def test_html_sidebar(app):
|
||||
# sourcelink.html
|
||||
assert '<h3>This Page</h3>' in result
|
||||
|
||||
assert isinstance(app.builder, StandaloneHTMLBuilder) # type-checking
|
||||
app.builder.add_sidebars('index', ctx)
|
||||
assert ctx['sidebars'] == ['sourcelink.html']
|
||||
|
||||
@ -433,6 +442,7 @@ def test_html_sidebar(app):
|
||||
# sourcelink.html
|
||||
assert '<h3>This Page</h3>' not in result
|
||||
|
||||
assert isinstance(app.builder, StandaloneHTMLBuilder) # type-checking
|
||||
app.builder.add_sidebars('index', ctx)
|
||||
assert ctx['sidebars'] == []
|
||||
|
||||
@ -462,7 +472,7 @@ def test_html_manpage(app, cached_etree_parse, fname, expect):
|
||||
testroot='toctree-glob',
|
||||
confoverrides={'html_baseurl': 'https://example.com/'},
|
||||
)
|
||||
def test_html_baseurl(app):
|
||||
def test_html_baseurl(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -482,7 +492,7 @@ def test_html_baseurl(app):
|
||||
'html_file_suffix': '.htm',
|
||||
},
|
||||
)
|
||||
def test_html_baseurl_and_html_file_suffix(app):
|
||||
def test_html_baseurl_and_html_file_suffix(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
result = (app.outdir / 'index.htm').read_text(encoding='utf8')
|
||||
@ -501,7 +511,7 @@ def test_html_baseurl_and_html_file_suffix(app):
|
||||
testroot='basic',
|
||||
srcdir='validate_html_extra_path',
|
||||
)
|
||||
def test_validate_html_extra_path(app):
|
||||
def test_validate_html_extra_path(app: SphinxTestApp) -> None:
|
||||
(app.confdir / '_static').mkdir(parents=True, exist_ok=True)
|
||||
app.config.html_extra_path = [
|
||||
'/path/to/not_found', # not found
|
||||
@ -525,7 +535,7 @@ def test_validate_html_extra_path(app):
|
||||
testroot='basic',
|
||||
srcdir='validate_html_static_path',
|
||||
)
|
||||
def test_validate_html_static_path(app):
|
||||
def test_validate_html_static_path(app: SphinxTestApp) -> None:
|
||||
(app.confdir / '_static').mkdir(parents=True, exist_ok=True)
|
||||
app.config.html_static_path = [
|
||||
'/path/to/not_found', # not found
|
||||
@ -549,7 +559,7 @@ def test_validate_html_static_path(app):
|
||||
testroot='basic',
|
||||
confoverrides={'html_permalinks': False},
|
||||
)
|
||||
def test_html_permalink_disable(app):
|
||||
def test_html_permalink_disable(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
|
||||
@ -561,7 +571,7 @@ def test_html_permalink_disable(app):
|
||||
testroot='basic',
|
||||
confoverrides={'html_permalinks_icon': '<span>[PERMALINK]</span>'},
|
||||
)
|
||||
def test_html_permalink_icon(app):
|
||||
def test_html_permalink_icon(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
|
||||
@ -573,7 +583,7 @@ def test_html_permalink_icon(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='html_signaturereturn_icon')
|
||||
def test_html_signaturereturn_icon(app):
|
||||
def test_html_signaturereturn_icon(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
|
||||
@ -585,7 +595,7 @@ def test_html_signaturereturn_icon(app):
|
||||
testroot='root',
|
||||
srcdir=os.urandom(4).hex(),
|
||||
)
|
||||
def test_html_remove_sources_before_write_gh_issue_10786(app):
|
||||
def test_html_remove_sources_before_write_gh_issue_10786(app: SphinxTestApp) -> None:
|
||||
# See: https://github.com/sphinx-doc/sphinx/issues/10786
|
||||
target = app.srcdir / 'img.png'
|
||||
|
||||
@ -668,7 +678,9 @@ def test_html_pep_695_one_type_per_line(app, cached_etree_parse):
|
||||
'python_trailing_comma_in_multi_line_signatures': False,
|
||||
},
|
||||
)
|
||||
def test_html_pep_695_trailing_comma_in_multi_line_signatures(app):
|
||||
def test_html_pep_695_trailing_comma_in_multi_line_signatures(
|
||||
app: SphinxTestApp,
|
||||
) -> None:
|
||||
app.build()
|
||||
fname = app.outdir / 'index.html'
|
||||
etree = etree_parse(fname)
|
||||
@ -718,7 +730,7 @@ def test_html_pep_695_trailing_comma_in_multi_line_signatures(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='directives-admonition-collapse')
|
||||
def test_html_admonition_collapse(app):
|
||||
def test_html_admonition_collapse(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
fname = app.outdir / 'index.html'
|
||||
etree = etree_parse(fname)
|
||||
|
@ -15,6 +15,8 @@ if TYPE_CHECKING:
|
||||
from typing import Literal
|
||||
from xml.etree.ElementTree import Element
|
||||
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
def tail_check(check: str) -> Callable[[Iterable[Element]], Literal[True]]:
|
||||
rex = re.compile(check)
|
||||
@ -497,7 +499,7 @@ def test_html5_output(app, cached_etree_parse, fname, path, check):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='markup-rubric')
|
||||
def test_html5_rubric(app):
|
||||
def test_html5_rubric(app: SphinxTestApp) -> None:
|
||||
def insert_invalid_rubric_heading_level(app, doctree, docname):
|
||||
if docname != 'index':
|
||||
return
|
||||
|
@ -4,6 +4,7 @@ from __future__ import annotations
|
||||
|
||||
import re
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
@ -11,9 +12,12 @@ import sphinx.builders.html
|
||||
from sphinx.builders.html._assets import _file_checksum
|
||||
from sphinx.errors import ThemeError
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='html_assets')
|
||||
def test_html_assets(app):
|
||||
def test_html_assets(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
# exclude_path and its family
|
||||
@ -108,7 +112,7 @@ def test_assets_order(app, monkeypatch):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='html_file_checksum')
|
||||
def test_file_checksum(app):
|
||||
def test_file_checksum(app: SphinxTestApp) -> None:
|
||||
app.add_css_file('stylesheet-a.css')
|
||||
app.add_css_file('stylesheet-b.css')
|
||||
app.add_css_file('https://example.com/custom.css')
|
||||
@ -165,7 +169,7 @@ def test_file_checksum_query_string() -> None:
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='html_assets')
|
||||
def test_javscript_loading_method(app):
|
||||
def test_javscript_loading_method(app: SphinxTestApp) -> None:
|
||||
app.add_js_file('normal.js')
|
||||
app.add_js_file('early.js', loading_method='async')
|
||||
app.add_js_file('late.js', loading_method='defer')
|
||||
|
@ -1,15 +1,20 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pygments
|
||||
import pytest
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
'html',
|
||||
testroot='reST-code-block',
|
||||
confoverrides={'html_codeblock_linenos_style': 'table'},
|
||||
)
|
||||
def test_html_codeblock_linenos_style_table(app):
|
||||
def test_html_codeblock_linenos_style_table(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
|
||||
@ -26,7 +31,7 @@ def test_html_codeblock_linenos_style_table(app):
|
||||
testroot='reST-code-block',
|
||||
confoverrides={'html_codeblock_linenos_style': 'inline'},
|
||||
)
|
||||
def test_html_codeblock_linenos_style_inline(app):
|
||||
def test_html_codeblock_linenos_style_inline(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
|
||||
@ -34,7 +39,7 @@ def test_html_codeblock_linenos_style_inline(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='reST-code-role')
|
||||
def test_html_code_role(app):
|
||||
def test_html_code_role(app: SphinxTestApp) -> None:
|
||||
if tuple(map(int, pygments.__version__.split('.')[:2])) >= (2, 19):
|
||||
sp = '<span class="w"> </span>'
|
||||
else:
|
||||
|
@ -5,6 +5,8 @@ from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Iterator
|
||||
|
||||
|
@ -2,12 +2,16 @@ from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import re
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root')
|
||||
def test_html_download(app):
|
||||
def test_html_download(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
# subdir/includes.html
|
||||
@ -42,7 +46,7 @@ def test_html_download(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='roles-download')
|
||||
def test_html_download_role(app):
|
||||
def test_html_download_role(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
digest = hashlib.md5(b'dummy.dat', usedforsecurity=False).hexdigest()
|
||||
assert (app.outdir / '_downloads' / digest / 'dummy.dat').exists()
|
||||
|
@ -1,13 +1,21 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
from unittest.mock import ANY, call, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from sphinx.builders.html import StandaloneHTMLBuilder
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='basic', confoverrides={'html_theme': 'alabaster'})
|
||||
def test_html_pygments_style_default(app):
|
||||
def test_html_pygments_style_default(app: SphinxTestApp) -> None:
|
||||
assert isinstance(app.builder, StandaloneHTMLBuilder) # type-checking
|
||||
style = app.builder.highlighter.formatter_args.get('style')
|
||||
assert style is not None
|
||||
assert style.__name__ == 'Alabaster'
|
||||
|
||||
|
||||
@ -16,8 +24,10 @@ def test_html_pygments_style_default(app):
|
||||
testroot='basic',
|
||||
confoverrides={'pygments_style': 'sphinx'},
|
||||
)
|
||||
def test_html_pygments_style_manually(app):
|
||||
def test_html_pygments_style_manually(app: SphinxTestApp) -> None:
|
||||
assert isinstance(app.builder, StandaloneHTMLBuilder) # type-checking
|
||||
style = app.builder.highlighter.formatter_args.get('style')
|
||||
assert style is not None
|
||||
assert style.__name__ == 'SphinxStyle'
|
||||
|
||||
|
||||
@ -26,18 +36,22 @@ def test_html_pygments_style_manually(app):
|
||||
testroot='basic',
|
||||
confoverrides={'html_theme': 'classic'},
|
||||
)
|
||||
def test_html_pygments_for_classic_theme(app):
|
||||
def test_html_pygments_for_classic_theme(app: SphinxTestApp) -> None:
|
||||
assert isinstance(app.builder, StandaloneHTMLBuilder) # type-checking
|
||||
style = app.builder.highlighter.formatter_args.get('style')
|
||||
assert style is not None
|
||||
assert style.__name__ == 'SphinxStyle'
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='basic')
|
||||
def test_html_dark_pygments_style_default(app):
|
||||
def test_html_dark_pygments_style_default(app: SphinxTestApp) -> None:
|
||||
assert isinstance(app.builder, StandaloneHTMLBuilder) # type-checking
|
||||
assert app.builder.dark_highlighter is None
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='highlight_options')
|
||||
def test_highlight_options(app):
|
||||
def test_highlight_options(app: SphinxTestApp) -> None:
|
||||
assert isinstance(app.builder, StandaloneHTMLBuilder) # type-checking
|
||||
subject = app.builder.highlighter
|
||||
with patch.object(
|
||||
subject,
|
||||
@ -79,7 +93,8 @@ def test_highlight_options(app):
|
||||
testroot='highlight_options',
|
||||
confoverrides={'highlight_options': {'default_option': True}},
|
||||
)
|
||||
def test_highlight_options_old(app):
|
||||
def test_highlight_options_old(app: SphinxTestApp) -> None:
|
||||
assert isinstance(app.builder, StandaloneHTMLBuilder) # type-checking
|
||||
subject = app.builder.highlighter
|
||||
with patch.object(
|
||||
subject,
|
||||
|
@ -2,14 +2,18 @@ from __future__ import annotations
|
||||
|
||||
import re
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import docutils
|
||||
import pytest
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('_http_teapot')
|
||||
@pytest.mark.sphinx('html', testroot='images')
|
||||
def test_html_remote_images(app):
|
||||
def test_html_remote_images(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -21,7 +25,7 @@ def test_html_remote_images(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='image-escape')
|
||||
def test_html_encoded_image(app):
|
||||
def test_html_encoded_image(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -30,7 +34,7 @@ def test_html_encoded_image(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='remote-logo')
|
||||
def test_html_remote_logo(app):
|
||||
def test_html_remote_logo(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -44,7 +48,7 @@ def test_html_remote_logo(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='local-logo')
|
||||
def test_html_local_logo(app):
|
||||
def test_html_local_logo(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -55,7 +59,7 @@ def test_html_local_logo(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='html_scaled_image_link')
|
||||
def test_html_scaled_image_link(app):
|
||||
def test_html_scaled_image_link(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
context = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
|
||||
@ -97,7 +101,7 @@ def test_html_scaled_image_link(app):
|
||||
|
||||
@pytest.mark.usefixtures('_http_teapot')
|
||||
@pytest.mark.sphinx('html', testroot='images')
|
||||
def test_copy_images(app):
|
||||
def test_copy_images(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
images_dir = Path(app.outdir) / '_images'
|
||||
|
@ -1,12 +1,19 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
from sphinx.builders.html import StandaloneHTMLBuilder
|
||||
from sphinx.errors import ConfigError
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='basic')
|
||||
def test_default_html_math_renderer(app):
|
||||
def test_default_html_math_renderer(app: SphinxTestApp) -> None:
|
||||
assert isinstance(app.builder, StandaloneHTMLBuilder) # type-checking
|
||||
assert app.builder.math_renderer_name == 'mathjax'
|
||||
|
||||
|
||||
@ -15,7 +22,8 @@ def test_default_html_math_renderer(app):
|
||||
testroot='basic',
|
||||
confoverrides={'extensions': ['sphinx.ext.mathjax']},
|
||||
)
|
||||
def test_html_math_renderer_is_mathjax(app):
|
||||
def test_html_math_renderer_is_mathjax(app: SphinxTestApp) -> None:
|
||||
assert isinstance(app.builder, StandaloneHTMLBuilder) # type-checking
|
||||
assert app.builder.math_renderer_name == 'mathjax'
|
||||
|
||||
|
||||
@ -24,7 +32,8 @@ def test_html_math_renderer_is_mathjax(app):
|
||||
testroot='basic',
|
||||
confoverrides={'extensions': ['sphinx.ext.imgmath']},
|
||||
)
|
||||
def test_html_math_renderer_is_imgmath(app):
|
||||
def test_html_math_renderer_is_imgmath(app: SphinxTestApp) -> None:
|
||||
assert isinstance(app.builder, StandaloneHTMLBuilder) # type-checking
|
||||
assert app.builder.math_renderer_name == 'imgmath'
|
||||
|
||||
|
||||
@ -47,8 +56,9 @@ def test_html_math_renderer_is_duplicated(make_app, app_params):
|
||||
testroot='basic',
|
||||
confoverrides={'extensions': ['sphinx.ext.imgmath', 'sphinx.ext.mathjax']},
|
||||
)
|
||||
def test_html_math_renderer_is_duplicated2(app):
|
||||
def test_html_math_renderer_is_duplicated2(app: SphinxTestApp) -> None:
|
||||
# case of both mathjax and another math_renderer is loaded
|
||||
assert isinstance(app.builder, StandaloneHTMLBuilder) # type-checking
|
||||
assert app.builder.math_renderer_name == 'imgmath' # The another one is chosen
|
||||
|
||||
|
||||
@ -60,7 +70,8 @@ def test_html_math_renderer_is_duplicated2(app):
|
||||
'html_math_renderer': 'imgmath',
|
||||
},
|
||||
)
|
||||
def test_html_math_renderer_is_chosen(app):
|
||||
def test_html_math_renderer_is_chosen(app: SphinxTestApp) -> None:
|
||||
assert isinstance(app.builder, StandaloneHTMLBuilder) # type-checking
|
||||
assert app.builder.math_renderer_name == 'imgmath'
|
||||
|
||||
|
||||
|
@ -3,16 +3,20 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.test_builders.xpath_data import FIGURE_CAPTION
|
||||
from tests.test_builders.xpath_util import check_xpath
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='numfig')
|
||||
@pytest.mark.test_params(shared_result='test_build_html_numfig')
|
||||
def test_numfig_disabled_warn(app):
|
||||
def test_numfig_disabled_warn(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
warnings = app.warning.getvalue()
|
||||
assert 'index.rst:47: WARNING: numfig is disabled. :numref: is ignored.' in warnings
|
||||
@ -80,7 +84,7 @@ def test_numfig_disabled(app, cached_etree_parse, fname, path, check, be_found):
|
||||
srcdir='test_numfig_without_numbered_toctree_warn',
|
||||
confoverrides={'numfig': True},
|
||||
)
|
||||
def test_numfig_without_numbered_toctree_warn(app):
|
||||
def test_numfig_without_numbered_toctree_warn(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
# remove :numbered: option
|
||||
index = (app.srcdir / 'index.rst').read_text(encoding='utf8')
|
||||
@ -319,7 +323,7 @@ def test_numfig_without_numbered_toctree(
|
||||
confoverrides={'numfig': True},
|
||||
)
|
||||
@pytest.mark.test_params(shared_result='test_build_html_numfig_on')
|
||||
def test_numfig_with_numbered_toctree_warn(app):
|
||||
def test_numfig_with_numbered_toctree_warn(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
warnings = app.warning.getvalue()
|
||||
assert (
|
||||
@ -554,7 +558,7 @@ def test_numfig_with_numbered_toctree(
|
||||
},
|
||||
)
|
||||
@pytest.mark.test_params(shared_result='test_build_html_numfig_format_warn')
|
||||
def test_numfig_with_prefix_warn(app):
|
||||
def test_numfig_with_prefix_warn(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
warnings = app.warning.getvalue()
|
||||
assert (
|
||||
@ -787,7 +791,7 @@ def test_numfig_with_prefix(app, cached_etree_parse, fname, path, check, be_foun
|
||||
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):
|
||||
def test_numfig_with_secnum_depth_warn(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
warnings = app.warning.getvalue()
|
||||
assert (
|
||||
|
@ -3,17 +3,24 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from typing import TYPE_CHECKING
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from sphinx.builders.html import StandaloneHTMLBuilder
|
||||
|
||||
from tests.test_builders.xpath_html_util import _intradocument_hyperlink_check
|
||||
from tests.test_builders.xpath_util import check_xpath
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='toctree-glob')
|
||||
def test_relations(app):
|
||||
def test_relations(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
assert isinstance(app.builder, StandaloneHTMLBuilder) # type-checking
|
||||
assert app.builder.relations['index'] == [None, None, 'foo']
|
||||
assert app.builder.relations['foo'] == ['index', 'index', 'bar/index']
|
||||
assert app.builder.relations['bar/index'] == ['index', 'foo', 'bar/bar_1']
|
||||
@ -33,8 +40,9 @@ def test_relations(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('singlehtml', testroot='toctree-empty')
|
||||
def test_singlehtml_toctree(app):
|
||||
def test_singlehtml_toctree(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
assert isinstance(app.builder, StandaloneHTMLBuilder) # type-checking
|
||||
try:
|
||||
app.builder._get_local_toctree('index')
|
||||
except AttributeError:
|
||||
@ -46,7 +54,7 @@ def test_singlehtml_toctree(app):
|
||||
testroot='toctree',
|
||||
srcdir='numbered-toctree',
|
||||
)
|
||||
def test_numbered_toctree(app):
|
||||
def test_numbered_toctree(app: SphinxTestApp) -> None:
|
||||
# give argument to :numbered: option
|
||||
index = (app.srcdir / 'index.rst').read_text(encoding='utf8')
|
||||
index = re.sub(':numbered:.*', ':numbered: 1', index)
|
||||
|
@ -10,6 +10,7 @@ from contextlib import chdir
|
||||
from pathlib import Path
|
||||
from shutil import copyfile
|
||||
from subprocess import CalledProcessError
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pygments
|
||||
import pytest
|
||||
@ -24,6 +25,9 @@ from sphinx.writers.latex import LaTeXTranslator
|
||||
|
||||
from tests.utils import http_server
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
STYLEFILES = [
|
||||
'article.cls',
|
||||
'fancyhdr.sty',
|
||||
@ -158,7 +162,7 @@ def test_build_latex_doc(app, engine, docclass, python_maximum_signature_line_le
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='root')
|
||||
def test_writer(app):
|
||||
def test_writer(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'sphinxtests.tex').read_text(encoding='utf8')
|
||||
|
||||
@ -212,7 +216,7 @@ def test_writer(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='basic')
|
||||
def test_latex_basic(app):
|
||||
def test_latex_basic(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -230,7 +234,7 @@ def test_latex_basic(app):
|
||||
'latex_documents': [('index', 'test.tex', 'title', 'author', 'manual')],
|
||||
},
|
||||
)
|
||||
def test_latex_basic_manual(app):
|
||||
def test_latex_basic_manual(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -245,7 +249,7 @@ def test_latex_basic_manual(app):
|
||||
'latex_documents': [('index', 'test.tex', 'title', 'author', 'howto')],
|
||||
},
|
||||
)
|
||||
def test_latex_basic_howto(app):
|
||||
def test_latex_basic_howto(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -261,7 +265,7 @@ def test_latex_basic_howto(app):
|
||||
'latex_documents': [('index', 'test.tex', 'title', 'author', 'manual')],
|
||||
},
|
||||
)
|
||||
def test_latex_basic_manual_ja(app):
|
||||
def test_latex_basic_manual_ja(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -277,7 +281,7 @@ def test_latex_basic_manual_ja(app):
|
||||
'latex_documents': [('index', 'test.tex', 'title', 'author', 'howto')],
|
||||
},
|
||||
)
|
||||
def test_latex_basic_howto_ja(app):
|
||||
def test_latex_basic_howto_ja(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -286,7 +290,7 @@ def test_latex_basic_howto_ja(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='latex-theme')
|
||||
def test_latex_theme(app):
|
||||
def test_latex_theme(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -299,7 +303,7 @@ def test_latex_theme(app):
|
||||
testroot='latex-theme',
|
||||
confoverrides={'latex_elements': {'papersize': 'b5paper', 'pointsize': '9pt'}},
|
||||
)
|
||||
def test_latex_theme_papersize(app):
|
||||
def test_latex_theme_papersize(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -312,7 +316,7 @@ def test_latex_theme_papersize(app):
|
||||
testroot='latex-theme',
|
||||
confoverrides={'latex_theme_options': {'papersize': 'b5paper', 'pointsize': '9pt'}},
|
||||
)
|
||||
def test_latex_theme_options(app):
|
||||
def test_latex_theme_options(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -325,7 +329,7 @@ def test_latex_theme_options(app):
|
||||
testroot='basic',
|
||||
confoverrides={'language': 'zh'},
|
||||
)
|
||||
def test_latex_additional_settings_for_language_code(app):
|
||||
def test_latex_additional_settings_for_language_code(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -339,7 +343,7 @@ def test_latex_additional_settings_for_language_code(app):
|
||||
testroot='basic',
|
||||
confoverrides={'language': 'el'},
|
||||
)
|
||||
def test_latex_additional_settings_for_greek(app):
|
||||
def test_latex_additional_settings_for_greek(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -350,7 +354,7 @@ def test_latex_additional_settings_for_greek(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='latex-title')
|
||||
def test_latex_title_after_admonitions(app):
|
||||
def test_latex_title_after_admonitions(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -364,7 +368,7 @@ def test_latex_title_after_admonitions(app):
|
||||
testroot='basic',
|
||||
confoverrides={'release': '1.0_0'},
|
||||
)
|
||||
def test_latex_release(app):
|
||||
def test_latex_release(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -379,7 +383,7 @@ def test_latex_release(app):
|
||||
testroot='numfig',
|
||||
confoverrides={'numfig': True},
|
||||
)
|
||||
def test_numref(app):
|
||||
def test_numref(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -444,7 +448,7 @@ def test_numref(app):
|
||||
},
|
||||
},
|
||||
)
|
||||
def test_numref_with_prefix1(app):
|
||||
def test_numref_with_prefix1(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -515,7 +519,7 @@ def test_numref_with_prefix1(app):
|
||||
},
|
||||
},
|
||||
)
|
||||
def test_numref_with_prefix2(app):
|
||||
def test_numref_with_prefix2(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -574,7 +578,7 @@ def test_numref_with_prefix2(app):
|
||||
testroot='numfig',
|
||||
confoverrides={'numfig': True, 'language': 'ja'},
|
||||
)
|
||||
def test_numref_with_language_ja(app):
|
||||
def test_numref_with_language_ja(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -625,7 +629,7 @@ def test_numref_with_language_ja(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='latex-numfig')
|
||||
def test_latex_obey_numfig_is_false(app):
|
||||
def test_latex_obey_numfig_is_false(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
result = (app.outdir / 'SphinxManual.tex').read_text(encoding='utf8')
|
||||
@ -640,7 +644,7 @@ def test_latex_obey_numfig_is_false(app):
|
||||
testroot='latex-numfig',
|
||||
confoverrides={'numfig': True, 'numfig_secnum_depth': 0},
|
||||
)
|
||||
def test_latex_obey_numfig_secnum_depth_is_zero(app):
|
||||
def test_latex_obey_numfig_secnum_depth_is_zero(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
result = (app.outdir / 'SphinxManual.tex').read_text(encoding='utf8')
|
||||
@ -655,7 +659,7 @@ def test_latex_obey_numfig_secnum_depth_is_zero(app):
|
||||
testroot='latex-numfig',
|
||||
confoverrides={'numfig': True, 'numfig_secnum_depth': 2, 'math_numsep': '-'},
|
||||
)
|
||||
def test_latex_obey_numfig_secnum_depth_is_two(app):
|
||||
def test_latex_obey_numfig_secnum_depth_is_two(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
result = (app.outdir / 'SphinxManual.tex').read_text(encoding='utf8')
|
||||
@ -670,7 +674,7 @@ def test_latex_obey_numfig_secnum_depth_is_two(app):
|
||||
testroot='latex-numfig',
|
||||
confoverrides={'numfig': True, 'math_numfig': False},
|
||||
)
|
||||
def test_latex_obey_numfig_but_math_numfig_false(app):
|
||||
def test_latex_obey_numfig_but_math_numfig_false(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
result = (app.outdir / 'SphinxManual.tex').read_text(encoding='utf8')
|
||||
@ -681,7 +685,7 @@ def test_latex_obey_numfig_but_math_numfig_false(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='basic')
|
||||
def test_latex_add_latex_package(app):
|
||||
def test_latex_add_latex_package(app: SphinxTestApp) -> None:
|
||||
app.add_latex_package('foo')
|
||||
app.add_latex_package('bar', 'baz')
|
||||
app.build(force_all=True)
|
||||
@ -691,7 +695,7 @@ def test_latex_add_latex_package(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='latex-babel')
|
||||
def test_babel_with_no_language_settings(app):
|
||||
def test_babel_with_no_language_settings(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -719,7 +723,7 @@ def test_babel_with_no_language_settings(app):
|
||||
testroot='latex-babel',
|
||||
confoverrides={'language': 'de'},
|
||||
)
|
||||
def test_babel_with_language_de(app):
|
||||
def test_babel_with_language_de(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -747,7 +751,7 @@ def test_babel_with_language_de(app):
|
||||
testroot='latex-babel',
|
||||
confoverrides={'language': 'ru'},
|
||||
)
|
||||
def test_babel_with_language_ru(app):
|
||||
def test_babel_with_language_ru(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -775,7 +779,7 @@ def test_babel_with_language_ru(app):
|
||||
testroot='latex-babel',
|
||||
confoverrides={'language': 'tr'},
|
||||
)
|
||||
def test_babel_with_language_tr(app):
|
||||
def test_babel_with_language_tr(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -803,7 +807,7 @@ def test_babel_with_language_tr(app):
|
||||
testroot='latex-babel',
|
||||
confoverrides={'language': 'ja'},
|
||||
)
|
||||
def test_babel_with_language_ja(app):
|
||||
def test_babel_with_language_ja(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -829,7 +833,7 @@ def test_babel_with_language_ja(app):
|
||||
testroot='latex-babel',
|
||||
confoverrides={'language': 'unknown'},
|
||||
)
|
||||
def test_babel_with_unknown_language(app):
|
||||
def test_babel_with_unknown_language(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -861,7 +865,7 @@ def test_babel_with_unknown_language(app):
|
||||
testroot='latex-babel',
|
||||
confoverrides={'language': 'de', 'latex_engine': 'lualatex'},
|
||||
)
|
||||
def test_polyglossia_with_language_de(app):
|
||||
def test_polyglossia_with_language_de(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -890,7 +894,7 @@ def test_polyglossia_with_language_de(app):
|
||||
testroot='latex-babel',
|
||||
confoverrides={'language': 'de-1901', 'latex_engine': 'lualatex'},
|
||||
)
|
||||
def test_polyglossia_with_language_de_1901(app):
|
||||
def test_polyglossia_with_language_de_1901(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -915,7 +919,7 @@ def test_polyglossia_with_language_de_1901(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='root')
|
||||
def test_footnote(app):
|
||||
def test_footnote(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'sphinxtests.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -953,7 +957,7 @@ def test_footnote(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='footnotes')
|
||||
def test_reference_in_caption_and_codeblock_in_footnote(app):
|
||||
def test_reference_in_caption_and_codeblock_in_footnote(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -1013,7 +1017,7 @@ def test_reference_in_caption_and_codeblock_in_footnote(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='footnotes')
|
||||
def test_footnote_referred_multiple_times(app):
|
||||
def test_footnote_referred_multiple_times(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -1039,7 +1043,7 @@ def test_footnote_referred_multiple_times(app):
|
||||
testroot='footnotes',
|
||||
confoverrides={'latex_show_urls': 'inline'},
|
||||
)
|
||||
def test_latex_show_urls_is_inline(app):
|
||||
def test_latex_show_urls_is_inline(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -1130,7 +1134,7 @@ def test_latex_show_urls_is_inline(app):
|
||||
testroot='footnotes',
|
||||
confoverrides={'latex_show_urls': 'footnote'},
|
||||
)
|
||||
def test_latex_show_urls_is_footnote(app):
|
||||
def test_latex_show_urls_is_footnote(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -1222,7 +1226,7 @@ def test_latex_show_urls_is_footnote(app):
|
||||
testroot='footnotes',
|
||||
confoverrides={'latex_show_urls': 'no'},
|
||||
)
|
||||
def test_latex_show_urls_is_no(app):
|
||||
def test_latex_show_urls_is_no(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -1299,14 +1303,14 @@ def test_latex_show_urls_is_no(app):
|
||||
'rst_prolog': '.. |URL| replace:: `text <https://www.example.com/>`__',
|
||||
},
|
||||
)
|
||||
def test_latex_show_urls_footnote_and_substitutions(app):
|
||||
def test_latex_show_urls_footnote_and_substitutions(app: SphinxTestApp) -> None:
|
||||
# hyperlinks in substitutions should not effect to make footnotes
|
||||
# See: https://github.com/sphinx-doc/sphinx/issues/4784
|
||||
test_latex_show_urls_is_footnote(app)
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='image-in-section')
|
||||
def test_image_in_section(app):
|
||||
def test_image_in_section(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -1329,13 +1333,13 @@ def test_image_in_section(app):
|
||||
testroot='basic',
|
||||
confoverrides={'latex_logo': 'notfound.jpg'},
|
||||
)
|
||||
def test_latex_logo_if_not_found(app):
|
||||
def test_latex_logo_if_not_found(app: SphinxTestApp) -> None:
|
||||
with pytest.raises(SphinxError):
|
||||
app.build(force_all=True)
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='toctree-maxdepth')
|
||||
def test_toctree_maxdepth_manual(app):
|
||||
def test_toctree_maxdepth_manual(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -1361,7 +1365,7 @@ def test_toctree_maxdepth_manual(app):
|
||||
]
|
||||
},
|
||||
)
|
||||
def test_toctree_maxdepth_howto(app):
|
||||
def test_toctree_maxdepth_howto(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -1377,7 +1381,7 @@ def test_toctree_maxdepth_howto(app):
|
||||
testroot='toctree-maxdepth',
|
||||
confoverrides={'root_doc': 'foo'},
|
||||
)
|
||||
def test_toctree_not_found(app):
|
||||
def test_toctree_not_found(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -1393,7 +1397,7 @@ def test_toctree_not_found(app):
|
||||
testroot='toctree-maxdepth',
|
||||
confoverrides={'root_doc': 'bar'},
|
||||
)
|
||||
def test_toctree_without_maxdepth(app):
|
||||
def test_toctree_without_maxdepth(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -1408,7 +1412,7 @@ def test_toctree_without_maxdepth(app):
|
||||
testroot='toctree-maxdepth',
|
||||
confoverrides={'root_doc': 'qux'},
|
||||
)
|
||||
def test_toctree_with_deeper_maxdepth(app):
|
||||
def test_toctree_with_deeper_maxdepth(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -1423,7 +1427,7 @@ def test_toctree_with_deeper_maxdepth(app):
|
||||
testroot='toctree-maxdepth',
|
||||
confoverrides={'latex_toplevel_sectioning': None},
|
||||
)
|
||||
def test_latex_toplevel_sectioning_is_None(app):
|
||||
def test_latex_toplevel_sectioning_is_None(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -1437,7 +1441,7 @@ def test_latex_toplevel_sectioning_is_None(app):
|
||||
testroot='toctree-maxdepth',
|
||||
confoverrides={'latex_toplevel_sectioning': 'part'},
|
||||
)
|
||||
def test_latex_toplevel_sectioning_is_part(app):
|
||||
def test_latex_toplevel_sectioning_is_part(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -1464,7 +1468,7 @@ def test_latex_toplevel_sectioning_is_part(app):
|
||||
],
|
||||
},
|
||||
)
|
||||
def test_latex_toplevel_sectioning_is_part_with_howto(app):
|
||||
def test_latex_toplevel_sectioning_is_part_with_howto(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -1480,7 +1484,7 @@ def test_latex_toplevel_sectioning_is_part_with_howto(app):
|
||||
testroot='toctree-maxdepth',
|
||||
confoverrides={'latex_toplevel_sectioning': 'chapter'},
|
||||
)
|
||||
def test_latex_toplevel_sectioning_is_chapter(app):
|
||||
def test_latex_toplevel_sectioning_is_chapter(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -1505,7 +1509,7 @@ def test_latex_toplevel_sectioning_is_chapter(app):
|
||||
],
|
||||
},
|
||||
)
|
||||
def test_latex_toplevel_sectioning_is_chapter_with_howto(app):
|
||||
def test_latex_toplevel_sectioning_is_chapter_with_howto(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -1519,7 +1523,7 @@ def test_latex_toplevel_sectioning_is_chapter_with_howto(app):
|
||||
testroot='toctree-maxdepth',
|
||||
confoverrides={'latex_toplevel_sectioning': 'section'},
|
||||
)
|
||||
def test_latex_toplevel_sectioning_is_section(app):
|
||||
def test_latex_toplevel_sectioning_is_section(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -1530,7 +1534,7 @@ def test_latex_toplevel_sectioning_is_section(app):
|
||||
|
||||
@skip_if_stylefiles_notfound
|
||||
@pytest.mark.sphinx('latex', testroot='maxlistdepth')
|
||||
def test_maxlistdepth_at_ten(app):
|
||||
def test_maxlistdepth_at_ten(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -1545,7 +1549,7 @@ def test_maxlistdepth_at_ten(app):
|
||||
confoverrides={'latex_table_style': []},
|
||||
)
|
||||
@pytest.mark.test_params(shared_result='latex-table')
|
||||
def test_latex_table_tabulars(app):
|
||||
def test_latex_table_tabulars(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
tables = {}
|
||||
@ -1623,7 +1627,7 @@ def test_latex_table_tabulars(app):
|
||||
confoverrides={'latex_table_style': []},
|
||||
)
|
||||
@pytest.mark.test_params(shared_result='latex-table')
|
||||
def test_latex_table_longtable(app):
|
||||
def test_latex_table_longtable(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
tables = {}
|
||||
@ -1691,7 +1695,7 @@ def test_latex_table_longtable(app):
|
||||
confoverrides={'latex_table_style': []},
|
||||
)
|
||||
@pytest.mark.test_params(shared_result='latex-table')
|
||||
def test_latex_table_complex_tables(app):
|
||||
def test_latex_table_complex_tables(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
tables = {}
|
||||
@ -1725,7 +1729,7 @@ def test_latex_table_complex_tables(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='latex-table')
|
||||
def test_latex_table_with_booktabs_and_colorrows(app):
|
||||
def test_latex_table_with_booktabs_and_colorrows(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
assert r'\PassOptionsToPackage{booktabs}{sphinx}' in result
|
||||
@ -1744,7 +1748,7 @@ def test_latex_table_with_booktabs_and_colorrows(app):
|
||||
testroot='latex-table',
|
||||
confoverrides={'templates_path': ['_mytemplates/latex']},
|
||||
)
|
||||
def test_latex_table_custom_template_caseA(app):
|
||||
def test_latex_table_custom_template_caseA(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
assert 'SALUT LES COPAINS' in result
|
||||
@ -1756,7 +1760,7 @@ def test_latex_table_custom_template_caseA(app):
|
||||
testroot='latex-table',
|
||||
confoverrides={'templates_path': ['_mytemplates']},
|
||||
)
|
||||
def test_latex_table_custom_template_caseB(app):
|
||||
def test_latex_table_custom_template_caseB(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
assert 'SALUT LES COPAINS' not in result
|
||||
@ -1764,14 +1768,14 @@ def test_latex_table_custom_template_caseB(app):
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='latex-table')
|
||||
@pytest.mark.test_params(shared_result='latex-table')
|
||||
def test_latex_table_custom_template_caseC(app):
|
||||
def test_latex_table_custom_template_caseC(app: SphinxTestApp) -> None:
|
||||
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):
|
||||
def test_latex_raw_directive(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
|
||||
@ -1787,7 +1791,7 @@ def test_latex_raw_directive(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='images')
|
||||
def test_latex_images(app):
|
||||
def test_latex_images(app: SphinxTestApp) -> None:
|
||||
with http_server(RemoteImageHandler, port=7777):
|
||||
app.build(force_all=True)
|
||||
|
||||
@ -1818,7 +1822,7 @@ def test_latex_images(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='latex-index')
|
||||
def test_latex_index(app):
|
||||
def test_latex_index(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
@ -1838,7 +1842,7 @@ def test_latex_index(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='latex-equations')
|
||||
def test_latex_equations(app):
|
||||
def test_latex_equations(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
@ -1852,7 +1856,7 @@ def test_latex_equations(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='image-in-parsed-literal')
|
||||
def test_latex_image_in_parsed_literal(app):
|
||||
def test_latex_image_in_parsed_literal(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
@ -1864,7 +1868,7 @@ def test_latex_image_in_parsed_literal(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='nested-enumerated-list')
|
||||
def test_latex_nested_enumerated_list(app):
|
||||
def test_latex_nested_enumerated_list(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
@ -1890,7 +1894,7 @@ def test_latex_nested_enumerated_list(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='footnotes')
|
||||
def test_latex_thebibliography(app):
|
||||
def test_latex_thebibliography(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
@ -1905,7 +1909,7 @@ def test_latex_thebibliography(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='glossary')
|
||||
def test_latex_glossary(app):
|
||||
def test_latex_glossary(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
@ -1939,7 +1943,7 @@ def test_latex_glossary(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='latex-labels')
|
||||
def test_latex_labels(app):
|
||||
def test_latex_labels(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
@ -2003,7 +2007,7 @@ def test_latex_labels(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='latex-figure-in-admonition')
|
||||
def test_latex_figure_in_admonition(app):
|
||||
def test_latex_figure_in_admonition(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
assert 'tabulary' not in result
|
||||
@ -2037,7 +2041,7 @@ def test_default_latex_documents():
|
||||
@skip_if_requested
|
||||
@skip_if_stylefiles_notfound
|
||||
@pytest.mark.sphinx('latex', testroot='latex-includegraphics')
|
||||
def test_includegraphics_oversized(app):
|
||||
def test_includegraphics_oversized(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
print(app.status.getvalue())
|
||||
print(app.warning.getvalue())
|
||||
@ -2045,7 +2049,7 @@ def test_includegraphics_oversized(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='index_on_title')
|
||||
def test_index_on_title(app):
|
||||
def test_index_on_title(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
assert (
|
||||
@ -2060,7 +2064,7 @@ def test_index_on_title(app):
|
||||
testroot='latex-unicode',
|
||||
confoverrides={'latex_engine': 'pdflatex'},
|
||||
)
|
||||
def test_texescape_for_non_unicode_supported_engine(app):
|
||||
def test_texescape_for_non_unicode_supported_engine(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -2075,7 +2079,7 @@ def test_texescape_for_non_unicode_supported_engine(app):
|
||||
testroot='latex-unicode',
|
||||
confoverrides={'latex_engine': 'xelatex'},
|
||||
)
|
||||
def test_texescape_for_unicode_supported_engine(app):
|
||||
def test_texescape_for_unicode_supported_engine(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
print(result)
|
||||
@ -2090,20 +2094,20 @@ def test_texescape_for_unicode_supported_engine(app):
|
||||
testroot='basic',
|
||||
confoverrides={'latex_elements': {'extrapackages': r'\usepackage{foo}'}},
|
||||
)
|
||||
def test_latex_elements_extrapackages(app):
|
||||
def test_latex_elements_extrapackages(app: SphinxTestApp) -> None:
|
||||
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):
|
||||
def test_latex_nested_tables(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
assert app.warning.getvalue() == ''
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='latex-container')
|
||||
def test_latex_container(app):
|
||||
def test_latex_container(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
assert r'\begin{sphinxuseclass}{classname}' in result
|
||||
@ -2111,7 +2115,7 @@ def test_latex_container(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='reST-code-role')
|
||||
def test_latex_code_role(app):
|
||||
def test_latex_code_role(app: SphinxTestApp) -> None:
|
||||
if tuple(map(int, pygments.__version__.split('.')[:2])) >= (2, 19):
|
||||
sp = r'\PYG{+w}{ }'
|
||||
else:
|
||||
@ -2147,7 +2151,7 @@ def test_latex_code_role(app):
|
||||
|
||||
@pytest.mark.usefixtures('_http_teapot')
|
||||
@pytest.mark.sphinx('latex', testroot='images')
|
||||
def test_copy_images(app):
|
||||
def test_copy_images(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
test_dir = Path(app.outdir)
|
||||
@ -2166,7 +2170,7 @@ def test_copy_images(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='latex-labels-before-module')
|
||||
def test_duplicated_labels_before_module(app):
|
||||
def test_duplicated_labels_before_module(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
content: str = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
|
||||
@ -2206,7 +2210,7 @@ def test_duplicated_labels_before_module(app):
|
||||
testroot='domain-py-python_maximum_signature_line_length',
|
||||
confoverrides={'python_maximum_signature_line_length': 23},
|
||||
)
|
||||
def test_one_parameter_per_line(app):
|
||||
def test_one_parameter_per_line(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
|
||||
@ -2287,7 +2291,7 @@ def test_one_parameter_per_line(app):
|
||||
'python_trailing_comma_in_multi_line_signatures': False,
|
||||
},
|
||||
)
|
||||
def test_one_parameter_per_line_without_trailing_comma(app):
|
||||
def test_one_parameter_per_line_without_trailing_comma(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
|
||||
@ -2296,7 +2300,7 @@ def test_one_parameter_per_line_without_trailing_comma(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='markup-rubric')
|
||||
def test_latex_rubric(app):
|
||||
def test_latex_rubric(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
content = (app.outdir / 'test.tex').read_text(encoding='utf8')
|
||||
assert r'\subsubsection*{This is a rubric}' in content
|
||||
@ -2304,7 +2308,7 @@ def test_latex_rubric(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='latex-contents-topic-sidebar')
|
||||
def test_latex_contents_topic_sidebar(app):
|
||||
def test_latex_contents_topic_sidebar(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
|
||||
|
@ -27,6 +27,7 @@ from sphinx.builders.linkcheck import (
|
||||
RateLimit,
|
||||
compile_linkcheck_allowed_redirects,
|
||||
)
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
from sphinx.util import requests
|
||||
from sphinx.util._pathlib import _StrPath
|
||||
|
||||
@ -438,7 +439,7 @@ def test_raises_for_invalid_status(app: SphinxTestApp) -> None:
|
||||
testroot='linkcheck-localserver-anchor',
|
||||
freshenv=True,
|
||||
)
|
||||
def test_incomplete_html_anchor(app):
|
||||
def test_incomplete_html_anchor(app: SphinxTestApp) -> None:
|
||||
class IncompleteHTMLDocumentHandler(BaseHTTPRequestHandler):
|
||||
protocol_version = 'HTTP/1.1'
|
||||
|
||||
@ -464,7 +465,7 @@ def test_incomplete_html_anchor(app):
|
||||
testroot='linkcheck-localserver-anchor',
|
||||
freshenv=True,
|
||||
)
|
||||
def test_decoding_error_anchor_ignored(app):
|
||||
def test_decoding_error_anchor_ignored(app: SphinxTestApp) -> None:
|
||||
class NonASCIIHandler(BaseHTTPRequestHandler):
|
||||
protocol_version = 'HTTP/1.1'
|
||||
|
||||
@ -969,7 +970,7 @@ def test_TooManyRedirects_on_HEAD(app, monkeypatch):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('linkcheck', testroot='linkcheck-localserver')
|
||||
def test_ignore_local_redirection(app):
|
||||
def test_ignore_local_redirection(app: SphinxTestApp) -> None:
|
||||
with serve_application(app, InfiniteRedirectOnHeadHandler) as address:
|
||||
app.config.linkcheck_ignore = [f'http://{address}/redirected']
|
||||
app.build()
|
||||
@ -1000,7 +1001,7 @@ class RemoteDomainRedirectHandler(InfiniteRedirectOnHeadHandler):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('linkcheck', testroot='linkcheck-localserver')
|
||||
def test_ignore_remote_redirection(app):
|
||||
def test_ignore_remote_redirection(app: SphinxTestApp) -> None:
|
||||
with serve_application(app, RemoteDomainRedirectHandler) as address:
|
||||
app.config.linkcheck_ignore = ['http://example.test']
|
||||
app.build()
|
||||
|
@ -2,15 +2,20 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import docutils
|
||||
import pytest
|
||||
|
||||
from sphinx.builders.manpage import default_man_pages
|
||||
from sphinx.config import Config
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('man', testroot='root')
|
||||
def test_all(app):
|
||||
def test_all(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
assert (app.outdir / 'sphinxtests.1').exists()
|
||||
|
||||
@ -38,7 +43,7 @@ def test_all(app):
|
||||
testroot='basic',
|
||||
confoverrides={'man_pages': [('index', 'title', None, [], 1)]},
|
||||
)
|
||||
def test_man_pages_empty_description(app):
|
||||
def test_man_pages_empty_description(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'title.1').read_text(encoding='utf8')
|
||||
@ -50,13 +55,13 @@ def test_man_pages_empty_description(app):
|
||||
testroot='basic',
|
||||
confoverrides={'man_make_section_directory': True},
|
||||
)
|
||||
def test_man_make_section_directory(app):
|
||||
def test_man_make_section_directory(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
assert (app.outdir / 'man1' / 'projectnamenotset.1').exists()
|
||||
|
||||
|
||||
@pytest.mark.sphinx('man', testroot='directive-code')
|
||||
def test_captioned_code_block(app):
|
||||
def test_captioned_code_block(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
content = (app.outdir / 'projectnamenotset.1').read_text(encoding='utf8')
|
||||
|
||||
@ -115,7 +120,7 @@ def test_default_man_pages() -> None:
|
||||
|
||||
|
||||
@pytest.mark.sphinx('man', testroot='markup-rubric')
|
||||
def test_rubric(app):
|
||||
def test_rubric(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
content = (app.outdir / 'projectnamenotset.1').read_text(encoding='utf8')
|
||||
assert 'This is a rubric\n' in content
|
||||
|
@ -6,6 +6,7 @@ import re
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from subprocess import CalledProcessError
|
||||
from typing import TYPE_CHECKING
|
||||
from unittest.mock import Mock
|
||||
|
||||
import pytest
|
||||
@ -15,9 +16,12 @@ from sphinx.config import Config
|
||||
from sphinx.util.docutils import new_document
|
||||
from sphinx.writers.texinfo import TexinfoTranslator
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('texinfo', testroot='root')
|
||||
def test_texinfo(app):
|
||||
def test_texinfo(app: SphinxTestApp) -> None:
|
||||
TexinfoTranslator.ignore_missing_images = True
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'sphinxtests.texi').read_text(encoding='utf8')
|
||||
@ -41,7 +45,7 @@ def test_texinfo(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('texinfo', testroot='markup-rubric')
|
||||
def test_texinfo_rubric(app):
|
||||
def test_texinfo_rubric(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
output = (app.outdir / 'projectnamenotset.texi').read_text(encoding='utf8')
|
||||
@ -51,7 +55,7 @@ def test_texinfo_rubric(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('texinfo', testroot='markup-citation')
|
||||
def test_texinfo_citation(app):
|
||||
def test_texinfo_citation(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
output = (app.outdir / 'projectnamenotset.texi').read_text(encoding='utf8')
|
||||
@ -84,10 +88,11 @@ def test_default_texinfo_documents() -> None:
|
||||
|
||||
|
||||
@pytest.mark.sphinx('texinfo', testroot='root')
|
||||
def test_texinfo_escape_id(app):
|
||||
def test_texinfo_escape_id(app: SphinxTestApp) -> None:
|
||||
settings = Mock(title='', texinfo_dir_entry='', texinfo_elements={})
|
||||
document = new_document('', settings)
|
||||
translator = app.builder.create_translator(document, app.builder)
|
||||
assert isinstance(translator, TexinfoTranslator) # type-checking
|
||||
|
||||
assert translator.escape_id('Hello world') == 'Hello world'
|
||||
assert translator.escape_id('Hello world') == 'Hello world'
|
||||
@ -99,7 +104,7 @@ def test_texinfo_escape_id(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('texinfo', testroot='footnotes')
|
||||
def test_texinfo_footnote(app):
|
||||
def test_texinfo_footnote(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
output = (app.outdir / 'projectnamenotset.texi').read_text(encoding='utf8')
|
||||
@ -107,7 +112,7 @@ def test_texinfo_footnote(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('texinfo', testroot='root')
|
||||
def test_texinfo_xrefs(app):
|
||||
def test_texinfo_xrefs(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
output = (app.outdir / 'sphinxtests.texi').read_text(encoding='utf8')
|
||||
assert re.search(r'@ref{\w+,,--plugin\.option}', output)
|
||||
@ -123,7 +128,7 @@ def test_texinfo_xrefs(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('texinfo', testroot='root')
|
||||
def test_texinfo_samp_with_variable(app):
|
||||
def test_texinfo_samp_with_variable(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
output = (app.outdir / 'sphinxtests.texi').read_text(encoding='utf8')
|
||||
@ -135,7 +140,7 @@ def test_texinfo_samp_with_variable(app):
|
||||
|
||||
@pytest.mark.usefixtures('_http_teapot')
|
||||
@pytest.mark.sphinx('texinfo', testroot='images')
|
||||
def test_copy_images(app):
|
||||
def test_copy_images(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
images_dir = Path(app.outdir) / 'projectnamenotset-figures'
|
||||
|
@ -7,6 +7,7 @@ from typing import TYPE_CHECKING
|
||||
import pytest
|
||||
from docutils.utils import column_width
|
||||
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
from sphinx.writers.text import MAXWIDTH, Cell, Table
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
@ -4,12 +4,16 @@ import os
|
||||
import re
|
||||
import sys
|
||||
import traceback
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
from sphinx._cli.util.errors import strip_escape_sequences
|
||||
from sphinx.errors import SphinxError
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
ENV_WARNINGS = """\
|
||||
{root}/autodoc_fodder.py:docstring of autodoc_fodder.MarkupError:\\d+: \
|
||||
WARNING: Explicit markup ends without a blank line; unexpected unindent. \\[docutils\\]
|
||||
@ -69,7 +73,7 @@ def _check_warnings(expected_warnings: str, warning: str) -> None:
|
||||
testroot='warnings',
|
||||
freshenv=True,
|
||||
)
|
||||
def test_html_warnings(app):
|
||||
def test_html_warnings(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
warnings_exp = HTML_WARNINGS.format(root=re.escape(app.srcdir.as_posix()))
|
||||
_check_warnings(warnings_exp, app.warning.getvalue())
|
||||
@ -81,7 +85,7 @@ def test_html_warnings(app):
|
||||
freshenv=True,
|
||||
exception_on_warning=True,
|
||||
)
|
||||
def test_html_warnings_exception_on_warning(app):
|
||||
def test_html_warnings_exception_on_warning(app: SphinxTestApp) -> None:
|
||||
try:
|
||||
app.build(force_all=True)
|
||||
pytest.fail('Expected an exception to be raised')
|
||||
@ -96,7 +100,7 @@ def test_html_warnings_exception_on_warning(app):
|
||||
testroot='warnings',
|
||||
freshenv=True,
|
||||
)
|
||||
def test_latex_warnings(app):
|
||||
def test_latex_warnings(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
warnings_exp = LATEX_WARNINGS.format(root=re.escape(app.srcdir.as_posix()))
|
||||
_check_warnings(warnings_exp, app.warning.getvalue())
|
||||
@ -107,7 +111,7 @@ def test_latex_warnings(app):
|
||||
testroot='warnings',
|
||||
freshenv=True,
|
||||
)
|
||||
def test_texinfo_warnings(app):
|
||||
def test_texinfo_warnings(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
warnings_exp = TEXINFO_WARNINGS.format(root=re.escape(app.srcdir.as_posix()))
|
||||
_check_warnings(warnings_exp, app.warning.getvalue())
|
||||
|
@ -3,9 +3,13 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
'dummy',
|
||||
@ -13,7 +17,7 @@ import pytest
|
||||
srcdir='test_builder',
|
||||
freshenv=True,
|
||||
)
|
||||
def test_incremental_reading(app):
|
||||
def test_incremental_reading(app: SphinxTestApp) -> None:
|
||||
# first reading
|
||||
updated = app.builder.read()
|
||||
assert set(updated) == app.env.found_docs == set(app.env.all_docs)
|
||||
@ -40,7 +44,7 @@ def test_incremental_reading(app):
|
||||
testroot='warnings',
|
||||
freshenv=True,
|
||||
)
|
||||
def test_incremental_reading_for_missing_files(app):
|
||||
def test_incremental_reading_for_missing_files(app: SphinxTestApp) -> None:
|
||||
# first reading
|
||||
updated = app.builder.read()
|
||||
assert set(updated) == app.env.found_docs == set(app.env.all_docs)
|
||||
|
@ -24,6 +24,8 @@ if TYPE_CHECKING:
|
||||
from collections.abc import Iterable
|
||||
from typing import TypeAlias
|
||||
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
CircularList: TypeAlias = list[int | 'CircularList']
|
||||
CircularDict: TypeAlias = dict[str, int | 'CircularDict']
|
||||
|
||||
@ -85,7 +87,7 @@ def test_config_opt_deprecated(recwarn):
|
||||
'modindex_common_prefix': 'path1,path2',
|
||||
},
|
||||
)
|
||||
def test_core_config(app):
|
||||
def test_core_config(app: SphinxTestApp) -> None:
|
||||
cfg = app.config
|
||||
|
||||
# simple values
|
||||
@ -448,7 +450,7 @@ def test_config_eol(logger, tmp_path):
|
||||
testroot='root',
|
||||
confoverrides={'root_doc': 123, 'language': 'foo', 'primary_domain': None},
|
||||
)
|
||||
def test_builtin_conf(app):
|
||||
def test_builtin_conf(app: SphinxTestApp) -> None:
|
||||
warnings = app.warning.getvalue()
|
||||
assert 'root_doc' in warnings, (
|
||||
'override on builtin "root_doc" should raise a type warning'
|
||||
@ -591,7 +593,7 @@ nitpick_warnings = [
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='nitpicky-warnings')
|
||||
def test_nitpick_base(app):
|
||||
def test_nitpick_base(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
warning = app.warning.getvalue().strip().split('\n')
|
||||
@ -611,7 +613,7 @@ def test_nitpick_base(app):
|
||||
},
|
||||
},
|
||||
)
|
||||
def test_nitpick_ignore(app):
|
||||
def test_nitpick_ignore(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
assert not len(app.warning.getvalue().strip())
|
||||
|
||||
@ -626,7 +628,7 @@ def test_nitpick_ignore(app):
|
||||
],
|
||||
},
|
||||
)
|
||||
def test_nitpick_ignore_regex1(app):
|
||||
def test_nitpick_ignore_regex1(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
assert not len(app.warning.getvalue().strip())
|
||||
|
||||
@ -641,7 +643,7 @@ def test_nitpick_ignore_regex1(app):
|
||||
],
|
||||
},
|
||||
)
|
||||
def test_nitpick_ignore_regex2(app):
|
||||
def test_nitpick_ignore_regex2(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
assert not len(app.warning.getvalue().strip())
|
||||
|
||||
@ -662,7 +664,7 @@ def test_nitpick_ignore_regex2(app):
|
||||
],
|
||||
},
|
||||
)
|
||||
def test_nitpick_ignore_regex_fullmatch(app):
|
||||
def test_nitpick_ignore_regex_fullmatch(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
warning = app.warning.getvalue().strip().split('\n')
|
||||
|
@ -12,6 +12,7 @@ from sphinx.config import (
|
||||
correct_copyright_year,
|
||||
evaluate_copyright_placeholders,
|
||||
)
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Callable, Iterator
|
||||
|
@ -2,6 +2,9 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pygments
|
||||
import pytest
|
||||
from docutils import nodes
|
||||
@ -10,6 +13,9 @@ from sphinx.config import Config
|
||||
from sphinx.directives.code import LiteralIncludeReader
|
||||
from sphinx.testing.util import etree_parse
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
DUMMY_CONFIG = Config({}, {})
|
||||
|
||||
|
||||
@ -282,7 +288,7 @@ def test_LiteralIncludeReader_diff(testroot, literal_inc_path):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('xml', testroot='directive-code')
|
||||
def test_code_block(app):
|
||||
def test_code_block(app: SphinxTestApp) -> None:
|
||||
app.build(filenames=[app.srcdir / 'index.rst'])
|
||||
et = etree_parse(app.outdir / 'index.xml')
|
||||
secs = et.findall('./section/section')
|
||||
@ -294,13 +300,13 @@ def test_code_block(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='directive-code')
|
||||
def test_force_option(app):
|
||||
def test_force_option(app: SphinxTestApp) -> None:
|
||||
app.build(filenames=[app.srcdir / 'force.rst'])
|
||||
assert 'force.rst' not in app.warning.getvalue()
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='directive-code')
|
||||
def test_code_block_caption_html(app):
|
||||
def test_code_block_caption_html(app: SphinxTestApp) -> None:
|
||||
app.build(filenames=[app.srcdir / 'caption.rst'])
|
||||
html = (app.outdir / 'caption.html').read_text(encoding='utf8')
|
||||
caption = (
|
||||
@ -314,7 +320,7 @@ def test_code_block_caption_html(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='directive-code')
|
||||
def test_code_block_caption_latex(app):
|
||||
def test_code_block_caption_latex(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
latex = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
caption = '\\sphinxSetupCaptionForVerbatim{caption \\sphinxstyleemphasis{test} rb}'
|
||||
@ -329,7 +335,7 @@ def test_code_block_caption_latex(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='directive-code')
|
||||
def test_code_block_namedlink_latex(app):
|
||||
def test_code_block_namedlink_latex(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
latex = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
label1 = (
|
||||
@ -354,7 +360,7 @@ def test_code_block_namedlink_latex(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='directive-code')
|
||||
def test_code_block_emphasize_latex(app):
|
||||
def test_code_block_emphasize_latex(app: SphinxTestApp) -> None:
|
||||
app.build(filenames=[app.srcdir / 'emphasize.rst'])
|
||||
latex = (
|
||||
(app.outdir / 'projectnamenotset.tex')
|
||||
@ -368,7 +374,7 @@ def test_code_block_emphasize_latex(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('xml', testroot='directive-code')
|
||||
def test_literal_include(app):
|
||||
def test_literal_include(app: SphinxTestApp) -> None:
|
||||
app.build(filenames=[app.srcdir / 'index.rst'])
|
||||
et = etree_parse(app.outdir / 'index.xml')
|
||||
secs = et.findall('./section/section')
|
||||
@ -380,7 +386,7 @@ def test_literal_include(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('xml', testroot='directive-code')
|
||||
def test_literal_include_block_start_with_comment_or_brank(app):
|
||||
def test_literal_include_block_start_with_comment_or_brank(app: SphinxTestApp) -> None:
|
||||
app.build(filenames=[app.srcdir / 'python.rst'])
|
||||
et = etree_parse(app.outdir / 'python.xml')
|
||||
secs = et.findall('./section/section')
|
||||
@ -396,7 +402,7 @@ def test_literal_include_block_start_with_comment_or_brank(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='directive-code')
|
||||
def test_literal_include_linenos(app):
|
||||
def test_literal_include_linenos(app: SphinxTestApp) -> None:
|
||||
if tuple(map(int, pygments.__version__.split('.')[:2])) >= (2, 19):
|
||||
sp = '<span class="w"> </span>'
|
||||
else:
|
||||
@ -425,7 +431,7 @@ def test_literal_include_linenos(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='directive-code')
|
||||
def test_literalinclude_file_whole_of_emptyline(app):
|
||||
def test_literalinclude_file_whole_of_emptyline(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
latex = (
|
||||
(app.outdir / 'projectnamenotset.tex')
|
||||
@ -444,7 +450,7 @@ def test_literalinclude_file_whole_of_emptyline(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='directive-code')
|
||||
def test_literalinclude_caption_html(app):
|
||||
def test_literalinclude_caption_html(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
html = (app.outdir / 'caption.html').read_text(encoding='utf8')
|
||||
caption = (
|
||||
@ -458,8 +464,8 @@ def test_literalinclude_caption_html(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='directive-code')
|
||||
def test_literalinclude_caption_latex(app):
|
||||
app.build(filenames='index')
|
||||
def test_literalinclude_caption_latex(app: SphinxTestApp) -> None:
|
||||
app.build(filenames=(Path('index'),))
|
||||
latex = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
caption = '\\sphinxSetupCaptionForVerbatim{caption \\sphinxstylestrong{test} py}'
|
||||
label = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:id2}}}'
|
||||
@ -473,8 +479,8 @@ def test_literalinclude_caption_latex(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='directive-code')
|
||||
def test_literalinclude_namedlink_latex(app):
|
||||
app.build(filenames='index')
|
||||
def test_literalinclude_namedlink_latex(app: SphinxTestApp) -> None:
|
||||
app.build(filenames=(Path('index'),))
|
||||
latex = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
label1 = (
|
||||
'\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:name-test-py}}}'
|
||||
@ -498,7 +504,7 @@ def test_literalinclude_namedlink_latex(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('xml', testroot='directive-code')
|
||||
def test_literalinclude_classes(app):
|
||||
def test_literalinclude_classes(app: SphinxTestApp) -> None:
|
||||
app.build(filenames=[app.srcdir / 'classes.rst'])
|
||||
et = etree_parse(app.outdir / 'classes.xml')
|
||||
secs = et.findall('./section/section')
|
||||
@ -515,7 +521,7 @@ def test_literalinclude_classes(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('xml', testroot='directive-code')
|
||||
def test_literalinclude_pydecorators(app):
|
||||
def test_literalinclude_pydecorators(app: SphinxTestApp) -> None:
|
||||
app.build(filenames=[app.srcdir / 'py-decorators.rst'])
|
||||
et = etree_parse(app.outdir / 'py-decorators.xml')
|
||||
secs = et.findall('./section/section')
|
||||
@ -551,7 +557,7 @@ def test_literalinclude_pydecorators(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='directive-code')
|
||||
def test_code_block_highlighted(app):
|
||||
def test_code_block_highlighted(app: SphinxTestApp) -> None:
|
||||
app.build(filenames=[app.srcdir / 'highlight.rst'])
|
||||
doctree = app.env.get_doctree('highlight')
|
||||
codeblocks = list(doctree.findall(nodes.literal_block))
|
||||
@ -563,7 +569,7 @@ def test_code_block_highlighted(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='directive-code')
|
||||
def test_linenothreshold(app):
|
||||
def test_linenothreshold(app: SphinxTestApp) -> None:
|
||||
if tuple(map(int, pygments.__version__.split('.')[:2])) >= (2, 19):
|
||||
sp = '<span class="w"> </span>'
|
||||
else:
|
||||
@ -595,7 +601,7 @@ def test_linenothreshold(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='directive-code')
|
||||
def test_code_block_dedent(app):
|
||||
def test_code_block_dedent(app: SphinxTestApp) -> None:
|
||||
app.build(filenames=[app.srcdir / 'dedent.rst'])
|
||||
doctree = app.env.get_doctree('dedent')
|
||||
codeblocks = list(doctree.findall(nodes.literal_block))
|
||||
|
@ -16,6 +16,7 @@ from sphinx.util.docutils import sphinx_domains
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.application import Sphinx
|
||||
from sphinx.environment import BuildEnvironment
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
def _doctree_for_test(
|
||||
@ -30,7 +31,7 @@ def _doctree_for_test(
|
||||
|
||||
|
||||
@pytest.mark.sphinx('text', testroot='object-description-sections')
|
||||
def test_object_description_sections(app):
|
||||
def test_object_description_sections(app: SphinxTestApp) -> None:
|
||||
doctree = _doctree_for_test(app, app.env, 'index')
|
||||
# <document>
|
||||
# <index>
|
||||
@ -58,7 +59,7 @@ def test_object_description_sections(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='_blank')
|
||||
def test_object_description_content_line_number(app):
|
||||
def test_object_description_content_line_number(app: SphinxTestApp) -> None:
|
||||
text = '.. py:function:: foo(bar)\n\n Some link here: :ref:`abc`\n'
|
||||
doc = restructuredtext.parse(app, text)
|
||||
xrefs = list(doc.findall(condition=addnodes.pending_xref))
|
||||
|
@ -3,13 +3,17 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
from docutils import nodes
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('text', testroot='directive-only')
|
||||
def test_sectioning(app):
|
||||
def test_sectioning(app: SphinxTestApp) -> None:
|
||||
def getsects(section):
|
||||
if not isinstance(section, nodes.section):
|
||||
return [getsects(n) for n in section.children]
|
||||
|
@ -1,14 +1,19 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
'html',
|
||||
testroot='root',
|
||||
confoverrides={'option_emphasise_placeholders': True},
|
||||
)
|
||||
def test_option_emphasise_placeholders(app):
|
||||
def test_option_emphasise_placeholders(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
content = (app.outdir / 'objects.html').read_text(encoding='utf8')
|
||||
assert '<em><span class="pre">TYPE</span></em>' in content
|
||||
@ -26,7 +31,7 @@ def test_option_emphasise_placeholders(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root')
|
||||
def test_option_emphasise_placeholders_default(app):
|
||||
def test_option_emphasise_placeholders_default(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
content = (app.outdir / 'objects.html').read_text(encoding='utf8')
|
||||
assert '<span class="pre">={TYPE}</span>' in content
|
||||
@ -40,7 +45,7 @@ def test_option_emphasise_placeholders_default(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root')
|
||||
def test_option_reference_with_value(app):
|
||||
def test_option_reference_with_value(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
content = (app.outdir / 'objects.html').read_text(encoding='utf-8')
|
||||
assert (
|
||||
|
@ -3,6 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
from docutils import nodes
|
||||
@ -11,6 +12,9 @@ from sphinx import addnodes
|
||||
from sphinx.testing import restructuredtext
|
||||
from sphinx.testing.util import assert_node
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='toctree-glob')
|
||||
def test_toctree(app):
|
||||
@ -159,7 +163,7 @@ def test_toctree_twice(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='directive-include')
|
||||
def test_include_include_read_event(app):
|
||||
def test_include_include_read_event(app: SphinxTestApp) -> None:
|
||||
sources_reported = []
|
||||
|
||||
def source_read_handler(_app, relative_path, parent_docname, source):
|
||||
|
@ -2,15 +2,20 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
from docutils import nodes
|
||||
|
||||
from sphinx.testing import restructuredtext
|
||||
from sphinx.testing.util import assert_node
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='_blank')
|
||||
def test_code_directive(app):
|
||||
def test_code_directive(app: SphinxTestApp) -> None:
|
||||
# normal case
|
||||
text = '.. code::\n\n print("hello world")\n'
|
||||
|
||||
@ -90,7 +95,7 @@ def test_csv_table_directive(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='_blank')
|
||||
def test_math_directive(app):
|
||||
def test_math_directive(app: SphinxTestApp) -> None:
|
||||
# normal case
|
||||
text = '.. math:: E = mc^2'
|
||||
doctree = restructuredtext.parse(app, text)
|
||||
|
@ -7,7 +7,7 @@ from docutils import nodes
|
||||
|
||||
from sphinx.addnodes import pending_xref
|
||||
from sphinx.testing import restructuredtext
|
||||
from sphinx.testing.util import assert_node, etree_parse
|
||||
from sphinx.testing.util import SphinxTestApp, assert_node, etree_parse
|
||||
|
||||
TYPE_CHECKING = False
|
||||
if TYPE_CHECKING:
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
from sphinx import addnodes
|
||||
@ -18,13 +20,16 @@ from sphinx.addnodes import (
|
||||
from sphinx.testing import restructuredtext
|
||||
from sphinx.testing.util import assert_node
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
'html',
|
||||
testroot='domain-py',
|
||||
freshenv=True,
|
||||
)
|
||||
def test_domain_py_canonical(app):
|
||||
def test_domain_py_canonical(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'canonical.html').read_text(encoding='utf8')
|
||||
@ -37,7 +42,7 @@ def test_domain_py_canonical(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='_blank')
|
||||
def test_canonical(app):
|
||||
def test_canonical(app: SphinxTestApp) -> None:
|
||||
text = '.. py:class:: io.StringIO\n :canonical: _io.StringIO'
|
||||
domain = app.env.domains.python_domain
|
||||
doctree = restructuredtext.parse(app, text)
|
||||
@ -70,7 +75,7 @@ def test_canonical(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='_blank')
|
||||
def test_canonical_definition_overrides(app):
|
||||
def test_canonical_definition_overrides(app: SphinxTestApp) -> None:
|
||||
text = (
|
||||
'.. py:class:: io.StringIO\n'
|
||||
' :canonical: _io.StringIO\n'
|
||||
@ -84,7 +89,7 @@ def test_canonical_definition_overrides(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='_blank')
|
||||
def test_canonical_definition_skip(app):
|
||||
def test_canonical_definition_skip(app: SphinxTestApp) -> None:
|
||||
text = (
|
||||
'.. py:class:: _io.StringIO\n'
|
||||
'.. py:class:: io.StringIO\n'
|
||||
@ -99,7 +104,7 @@ def test_canonical_definition_skip(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='_blank')
|
||||
def test_canonical_duplicated(app):
|
||||
def test_canonical_duplicated(app: SphinxTestApp) -> None:
|
||||
text = (
|
||||
'.. py:class:: mypackage.StringIO\n'
|
||||
' :canonical: _io.StringIO\n'
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
from sphinx import addnodes
|
||||
@ -17,6 +19,9 @@ from sphinx.domains.rst import parse_directive
|
||||
from sphinx.testing import restructuredtext
|
||||
from sphinx.testing.util import assert_node
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
def test_parse_directive() -> None:
|
||||
s = parse_directive(' foö ')
|
||||
@ -33,7 +38,7 @@ def test_parse_directive() -> None:
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='_blank')
|
||||
def test_rst_directive(app):
|
||||
def test_rst_directive(app: SphinxTestApp) -> None:
|
||||
# bare
|
||||
text = '.. rst:directive:: toctree'
|
||||
doctree = restructuredtext.parse(app, text)
|
||||
@ -82,7 +87,7 @@ def test_rst_directive(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='_blank')
|
||||
def test_rst_directive_with_argument(app):
|
||||
def test_rst_directive_with_argument(app: SphinxTestApp) -> None:
|
||||
text = '.. rst:directive:: .. toctree:: foo bar baz'
|
||||
doctree = restructuredtext.parse(app, text)
|
||||
assert_node(
|
||||
@ -116,7 +121,7 @@ def test_rst_directive_with_argument(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='_blank')
|
||||
def test_rst_directive_option(app):
|
||||
def test_rst_directive_option(app: SphinxTestApp) -> None:
|
||||
text = '.. rst:directive:option:: foo'
|
||||
doctree = restructuredtext.parse(app, text)
|
||||
assert_node(
|
||||
@ -143,7 +148,7 @@ def test_rst_directive_option(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='_blank')
|
||||
def test_rst_directive_option_with_argument(app):
|
||||
def test_rst_directive_option_with_argument(app: SphinxTestApp) -> None:
|
||||
text = '.. rst:directive:option:: foo: bar baz'
|
||||
doctree = restructuredtext.parse(app, text)
|
||||
assert_node(
|
||||
@ -179,7 +184,7 @@ def test_rst_directive_option_with_argument(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='_blank')
|
||||
def test_rst_directive_option_type(app):
|
||||
def test_rst_directive_option_type(app: SphinxTestApp) -> None:
|
||||
text = '.. rst:directive:option:: foo\n :type: directives.flags\n'
|
||||
doctree = restructuredtext.parse(app, text)
|
||||
assert_node(
|
||||
@ -260,7 +265,7 @@ def test_rst_directive_and_directive_option(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='_blank')
|
||||
def test_rst_role(app):
|
||||
def test_rst_role(app: SphinxTestApp) -> None:
|
||||
text = '.. rst:role:: ref'
|
||||
doctree = restructuredtext.parse(app, text)
|
||||
assert_node(
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
@ -23,6 +24,9 @@ from sphinx.domains.std import StandardDomain
|
||||
from sphinx.testing import restructuredtext
|
||||
from sphinx.testing.util import assert_node
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
def test_process_doc_handle_figure_caption() -> None:
|
||||
env = mock.Mock(domaindata={})
|
||||
@ -90,7 +94,7 @@ def test_get_full_qualified_name() -> None:
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='_blank')
|
||||
def test_cmd_option_with_optional_value(app):
|
||||
def test_cmd_option_with_optional_value(app: SphinxTestApp) -> None:
|
||||
text = '.. option:: -j[=N]'
|
||||
doctree = restructuredtext.parse(app, text)
|
||||
assert_node(
|
||||
@ -117,7 +121,7 @@ def test_cmd_option_with_optional_value(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='_blank')
|
||||
def test_cmd_option_starting_with_bracket(app):
|
||||
def test_cmd_option_starting_with_bracket(app: SphinxTestApp) -> None:
|
||||
text = '.. option:: [enable=]PATTERN'
|
||||
doctree = restructuredtext.parse(app, text)
|
||||
assert_node(
|
||||
@ -244,7 +248,7 @@ def test_glossary(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='_blank')
|
||||
def test_glossary_warning(app):
|
||||
def test_glossary_warning(app: SphinxTestApp) -> None:
|
||||
# empty line between terms
|
||||
text = '.. glossary::\n\n term1\n\n term2\n'
|
||||
restructuredtext.parse(app, text, 'case1')
|
||||
@ -374,7 +378,7 @@ def test_glossary_sorted(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='_blank')
|
||||
def test_glossary_alphanumeric(app):
|
||||
def test_glossary_alphanumeric(app: SphinxTestApp) -> None:
|
||||
text = '.. glossary::\n\n 1\n /\n'
|
||||
restructuredtext.parse(app, text)
|
||||
objects = list(app.env.domains.standard_domain.get_objects())
|
||||
@ -383,7 +387,7 @@ def test_glossary_alphanumeric(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='_blank')
|
||||
def test_glossary_conflicted_labels(app):
|
||||
def test_glossary_conflicted_labels(app: SphinxTestApp) -> None:
|
||||
text = '.. _term-foo:\n.. glossary::\n\n foo\n'
|
||||
restructuredtext.parse(app, text)
|
||||
objects = list(app.env.domains.standard_domain.get_objects())
|
||||
@ -391,7 +395,7 @@ def test_glossary_conflicted_labels(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='_blank')
|
||||
def test_cmdoption(app):
|
||||
def test_cmdoption(app: SphinxTestApp) -> None:
|
||||
text = '.. program:: ls\n\n.. option:: -l\n'
|
||||
domain = app.env.domains.standard_domain
|
||||
doctree = restructuredtext.parse(app, text)
|
||||
@ -418,7 +422,7 @@ def test_cmdoption(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='_blank')
|
||||
def test_cmdoption_for_None(app):
|
||||
def test_cmdoption_for_None(app: SphinxTestApp) -> None:
|
||||
text = '.. program:: ls\n.. program:: None\n\n.. option:: -l\n'
|
||||
domain = app.env.domains.standard_domain
|
||||
doctree = restructuredtext.parse(app, text)
|
||||
@ -445,7 +449,7 @@ def test_cmdoption_for_None(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='_blank')
|
||||
def test_multiple_cmdoptions(app):
|
||||
def test_multiple_cmdoptions(app: SphinxTestApp) -> None:
|
||||
text = '.. program:: cmd\n\n.. option:: -o directory, --output directory\n'
|
||||
domain = app.env.domains.standard_domain
|
||||
doctree = restructuredtext.parse(app, text)
|
||||
@ -486,7 +490,7 @@ def test_multiple_cmdoptions(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='_blank')
|
||||
def test_disabled_docref(app):
|
||||
def test_disabled_docref(app: SphinxTestApp) -> None:
|
||||
text = ':doc:`index`\n:doc:`!index`\n'
|
||||
doctree = restructuredtext.parse(app, text)
|
||||
assert_node(
|
||||
@ -501,7 +505,7 @@ def test_disabled_docref(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='_blank')
|
||||
def test_labeled_rubric(app):
|
||||
def test_labeled_rubric(app: SphinxTestApp) -> None:
|
||||
text = '.. _label:\n.. rubric:: blah *blah* blah\n'
|
||||
restructuredtext.parse(app, text)
|
||||
|
||||
@ -511,7 +515,7 @@ def test_labeled_rubric(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='_blank')
|
||||
def test_labeled_definition(app):
|
||||
def test_labeled_definition(app: SphinxTestApp) -> None:
|
||||
text = (
|
||||
'.. _label1:\n'
|
||||
'\n'
|
||||
@ -534,7 +538,7 @@ def test_labeled_definition(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='_blank')
|
||||
def test_labeled_field(app):
|
||||
def test_labeled_field(app: SphinxTestApp) -> None:
|
||||
text = (
|
||||
'.. _label1:\n'
|
||||
'\n'
|
||||
@ -561,7 +565,7 @@ def test_labeled_field(app):
|
||||
testroot='manpage_url',
|
||||
confoverrides={'manpages_url': 'https://example.com/{page}.{section}'},
|
||||
)
|
||||
def test_html_manpage(app):
|
||||
def test_html_manpage(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
|
@ -4,6 +4,7 @@ from __future__ import annotations
|
||||
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
@ -19,6 +20,9 @@ from sphinx.environment import (
|
||||
_differing_config_keys,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='basic', copy_test_root=True)
|
||||
def test_config_status(make_app, app_params):
|
||||
@ -66,7 +70,7 @@ def test_config_status(make_app, app_params):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='root')
|
||||
def test_images(app):
|
||||
def test_images(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
tree = app.env.get_doctree('images')
|
||||
@ -111,7 +115,7 @@ def test_images(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='root')
|
||||
def test_object_inventory(app):
|
||||
def test_object_inventory(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
refs = app.env.domaindata['py']['objects']
|
||||
|
||||
@ -148,7 +152,7 @@ def test_object_inventory(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='basic')
|
||||
def test_env_relfn2path(app):
|
||||
def test_env_relfn2path(app: SphinxTestApp) -> None:
|
||||
# relative filename and root document
|
||||
relfn, absfn = app.env.relfn2path('logo.jpg', 'index')
|
||||
assert relfn == 'logo.jpg'
|
||||
|
@ -2,18 +2,23 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
from sphinx.environment.adapters.indexentries import IndexEntries
|
||||
from sphinx.testing import restructuredtext
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
'dummy',
|
||||
testroot='root',
|
||||
freshenv=True,
|
||||
)
|
||||
def test_create_single_index(app):
|
||||
def test_create_single_index(app: SphinxTestApp) -> None:
|
||||
text = (
|
||||
'.. index:: docutils\n'
|
||||
'.. index:: Python\n'
|
||||
@ -79,7 +84,7 @@ def test_create_single_index(app):
|
||||
testroot='root',
|
||||
freshenv=True,
|
||||
)
|
||||
def test_create_pair_index(app):
|
||||
def test_create_pair_index(app: SphinxTestApp) -> None:
|
||||
text = (
|
||||
'.. index:: pair: docutils; reStructuredText\n'
|
||||
'.. index:: pair: Python; interpreter\n'
|
||||
@ -146,7 +151,7 @@ def test_create_pair_index(app):
|
||||
testroot='root',
|
||||
freshenv=True,
|
||||
)
|
||||
def test_create_triple_index(app):
|
||||
def test_create_triple_index(app: SphinxTestApp) -> None:
|
||||
text = '.. index:: triple: foo; bar; baz\n.. index:: triple: Python; Sphinx; reST\n'
|
||||
restructuredtext.parse(app, text)
|
||||
index = IndexEntries(app.env).create_index(app.builder)
|
||||
@ -178,7 +183,7 @@ def test_create_triple_index(app):
|
||||
testroot='root',
|
||||
freshenv=True,
|
||||
)
|
||||
def test_create_see_index(app):
|
||||
def test_create_see_index(app: SphinxTestApp) -> None:
|
||||
text = (
|
||||
'.. index:: see: docutils; reStructuredText\n'
|
||||
'.. index:: see: Python; interpreter\n'
|
||||
@ -197,7 +202,7 @@ def test_create_see_index(app):
|
||||
testroot='root',
|
||||
freshenv=True,
|
||||
)
|
||||
def test_create_seealso_index(app):
|
||||
def test_create_seealso_index(app: SphinxTestApp) -> None:
|
||||
text = (
|
||||
'.. index:: seealso: docutils; reStructuredText\n'
|
||||
'.. index:: seealso: Python; interpreter\n'
|
||||
@ -222,7 +227,7 @@ def test_create_seealso_index(app):
|
||||
testroot='root',
|
||||
freshenv=True,
|
||||
)
|
||||
def test_create_main_index(app):
|
||||
def test_create_main_index(app: SphinxTestApp) -> None:
|
||||
text = (
|
||||
'.. index:: !docutils\n'
|
||||
'.. index:: docutils\n'
|
||||
@ -247,7 +252,7 @@ def test_create_main_index(app):
|
||||
testroot='root',
|
||||
freshenv=True,
|
||||
)
|
||||
def test_create_index_with_name(app):
|
||||
def test_create_index_with_name(app: SphinxTestApp) -> None:
|
||||
text = (
|
||||
'.. index:: single: docutils\n'
|
||||
' :name: ref1\n'
|
||||
@ -275,7 +280,7 @@ def test_create_index_with_name(app):
|
||||
testroot='root',
|
||||
freshenv=True,
|
||||
)
|
||||
def test_create_index_by_key(app):
|
||||
def test_create_index_by_key(app: SphinxTestApp) -> None:
|
||||
# At present, only glossary directive is able to create index key
|
||||
text = '.. glossary::\n\n docutils\n Python\n スフィンクス : ス\n'
|
||||
restructuredtext.parse(app, text)
|
||||
|
@ -2,13 +2,18 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
from sphinx.util._pathlib import _StrPath
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='environment-record-dependencies')
|
||||
def test_record_dependencies_cleared(app):
|
||||
def test_record_dependencies_cleared(app: SphinxTestApp) -> None:
|
||||
app.builder.read()
|
||||
assert 'index' not in app.env.dependencies
|
||||
assert app.env.dependencies['api'] == {_StrPath('example_module.py')}
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
from docutils import nodes
|
||||
from docutils.nodes import bullet_list, list_item, literal, reference, title
|
||||
@ -12,6 +14,9 @@ from sphinx.builders.html import StandaloneHTMLBuilder
|
||||
from sphinx.environment.adapters.toctree import document_toc, global_toctree_for_doc
|
||||
from sphinx.testing.util import assert_node
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('xml', testroot='toctree')
|
||||
@pytest.mark.test_params(shared_result='test_environment_toctree_basic')
|
||||
@ -342,7 +347,7 @@ def test_domain_objects(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='toctree-domain-objects')
|
||||
def test_domain_objects_document_scoping(app):
|
||||
def test_domain_objects_document_scoping(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
# tocs
|
||||
|
@ -6,13 +6,18 @@ source file translated by test_build.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.test_extensions.autodoc_util import do_autodoc
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autoattribute(app):
|
||||
def test_autoattribute(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'attribute', 'target.Class.attr')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -26,7 +31,7 @@ def test_autoattribute(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autoattribute_novalue(app):
|
||||
def test_autoattribute_novalue(app: SphinxTestApp) -> None:
|
||||
options = {'no-value': None}
|
||||
actual = do_autodoc(app, 'attribute', 'target.Class.attr', options)
|
||||
assert list(actual) == [
|
||||
@ -40,7 +45,7 @@ def test_autoattribute_novalue(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autoattribute_typed_variable(app):
|
||||
def test_autoattribute_typed_variable(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'attribute', 'target.typed_vars.Class.attr2')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -52,7 +57,7 @@ def test_autoattribute_typed_variable(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autoattribute_typed_variable_in_alias(app):
|
||||
def test_autoattribute_typed_variable_in_alias(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'attribute', 'target.typed_vars.Alias.attr2')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -64,7 +69,7 @@ def test_autoattribute_typed_variable_in_alias(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autoattribute_instance_variable(app):
|
||||
def test_autoattribute_instance_variable(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'attribute', 'target.typed_vars.Class.attr4')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -78,7 +83,7 @@ def test_autoattribute_instance_variable(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autoattribute_instance_variable_in_alias(app):
|
||||
def test_autoattribute_instance_variable_in_alias(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'attribute', 'target.typed_vars.Alias.attr4')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -92,7 +97,7 @@ def test_autoattribute_instance_variable_in_alias(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autoattribute_instance_variable_without_comment(app):
|
||||
def test_autoattribute_instance_variable_without_comment(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'attribute', 'target.instance_variable.Bar.attr4')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -103,7 +108,7 @@ def test_autoattribute_instance_variable_without_comment(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autoattribute_slots_variable_list(app):
|
||||
def test_autoattribute_slots_variable_list(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'attribute', 'target.slots.Foo.attr')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -114,7 +119,7 @@ def test_autoattribute_slots_variable_list(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autoattribute_slots_variable_dict(app):
|
||||
def test_autoattribute_slots_variable_dict(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'attribute', 'target.slots.Bar.attr1')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -128,7 +133,7 @@ def test_autoattribute_slots_variable_dict(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autoattribute_slots_variable_str(app):
|
||||
def test_autoattribute_slots_variable_str(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'attribute', 'target.slots.Baz.attr')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -139,7 +144,7 @@ def test_autoattribute_slots_variable_str(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autoattribute_GenericAlias(app):
|
||||
def test_autoattribute_GenericAlias(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'attribute', 'target.genericalias.Class.T')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -154,7 +159,7 @@ def test_autoattribute_GenericAlias(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autoattribute_hide_value(app):
|
||||
def test_autoattribute_hide_value(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'attribute', 'target.hide_value.Foo.SENTINEL1')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
|
@ -12,9 +12,12 @@ import pytest
|
||||
|
||||
from tests.test_extensions.autodoc_util import do_autodoc
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_classes(app):
|
||||
def test_classes(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'function', 'target.classes.Foo')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -49,7 +52,7 @@ def test_classes(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_instance_variable(app):
|
||||
def test_instance_variable(app: SphinxTestApp) -> None:
|
||||
options = {'members': None}
|
||||
actual = do_autodoc(app, 'class', 'target.instance_variable.Bar', options)
|
||||
assert list(actual) == [
|
||||
@ -73,7 +76,7 @@ def test_instance_variable(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_inherited_instance_variable(app):
|
||||
def test_inherited_instance_variable(app: SphinxTestApp) -> None:
|
||||
options = {
|
||||
'members': None,
|
||||
'inherited-members': None,
|
||||
@ -106,7 +109,7 @@ def test_inherited_instance_variable(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_uninitialized_attributes(app):
|
||||
def test_uninitialized_attributes(app: SphinxTestApp) -> None:
|
||||
options = {
|
||||
'members': None,
|
||||
'inherited-members': None,
|
||||
@ -137,7 +140,7 @@ def test_uninitialized_attributes(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_undocumented_uninitialized_attributes(app):
|
||||
def test_undocumented_uninitialized_attributes(app: SphinxTestApp) -> None:
|
||||
options = {
|
||||
'members': None,
|
||||
'inherited-members': None,
|
||||
@ -179,7 +182,7 @@ def test_undocumented_uninitialized_attributes(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_decorators(app):
|
||||
def test_decorators(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'class', 'target.decorator.Baz')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -206,7 +209,7 @@ def test_decorators(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_properties(app):
|
||||
def test_properties(app: SphinxTestApp) -> None:
|
||||
options = {'members': None}
|
||||
actual = do_autodoc(app, 'class', 'target.properties.Foo', options)
|
||||
assert list(actual) == [
|
||||
@ -250,7 +253,7 @@ def test_properties(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_slots_attribute(app):
|
||||
def test_slots_attribute(app: SphinxTestApp) -> None:
|
||||
options = {'members': None}
|
||||
actual = do_autodoc(app, 'class', 'target.slots.Bar', options)
|
||||
assert list(actual) == [
|
||||
@ -277,7 +280,7 @@ def test_slots_attribute(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_show_inheritance_for_subclass_of_generic_type(app):
|
||||
def test_show_inheritance_for_subclass_of_generic_type(app: SphinxTestApp) -> None:
|
||||
options = {'show-inheritance': None}
|
||||
actual = do_autodoc(app, 'class', 'target.classes.Quux', options)
|
||||
assert list(actual) == [
|
||||
@ -293,7 +296,7 @@ def test_show_inheritance_for_subclass_of_generic_type(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_show_inheritance_for_decendants_of_generic_type(app):
|
||||
def test_show_inheritance_for_decendants_of_generic_type(app: SphinxTestApp) -> None:
|
||||
options = {'show-inheritance': None}
|
||||
actual = do_autodoc(app, 'class', 'target.classes.Corge', options)
|
||||
assert list(actual) == [
|
||||
@ -307,7 +310,7 @@ def test_show_inheritance_for_decendants_of_generic_type(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autodoc_process_bases(app):
|
||||
def test_autodoc_process_bases(app: SphinxTestApp) -> None:
|
||||
def autodoc_process_bases(app, name, obj, options, bases):
|
||||
assert name == 'target.classes.Quux'
|
||||
assert obj.__module__ == 'target.classes'
|
||||
@ -335,7 +338,7 @@ def test_autodoc_process_bases(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_class_doc_from_class(app):
|
||||
def test_class_doc_from_class(app: SphinxTestApp) -> None:
|
||||
options = {
|
||||
'members': None,
|
||||
'class-doc-from': 'class',
|
||||
@ -352,7 +355,7 @@ def test_class_doc_from_class(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_class_doc_from_init(app):
|
||||
def test_class_doc_from_init(app: SphinxTestApp) -> None:
|
||||
options = {
|
||||
'members': None,
|
||||
'class-doc-from': 'init',
|
||||
@ -369,7 +372,7 @@ def test_class_doc_from_init(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_class_doc_from_both(app):
|
||||
def test_class_doc_from_both(app: SphinxTestApp) -> None:
|
||||
options = {
|
||||
'members': None,
|
||||
'class-doc-from': 'both',
|
||||
@ -388,7 +391,7 @@ def test_class_doc_from_both(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_class_alias(app):
|
||||
def test_class_alias(app: SphinxTestApp) -> None:
|
||||
def autodoc_process_docstring(*args):
|
||||
"""A handler always raises an error.
|
||||
This confirms this handler is never called for class aliases.
|
||||
@ -407,7 +410,7 @@ def test_class_alias(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_class_alias_having_doccomment(app):
|
||||
def test_class_alias_having_doccomment(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'class', 'target.classes.OtherAlias')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -420,7 +423,7 @@ def test_class_alias_having_doccomment(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_class_alias_for_imported_object_having_doccomment(app):
|
||||
def test_class_alias_for_imported_object_having_doccomment(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'class', 'target.classes.IntAlias')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -433,7 +436,7 @@ def test_class_alias_for_imported_object_having_doccomment(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_coroutine(app):
|
||||
def test_coroutine(app: SphinxTestApp) -> None:
|
||||
options = {'members': None}
|
||||
actual = do_autodoc(app, 'class', 'target.coroutine.AsyncClass', options)
|
||||
assert list(actual) == [
|
||||
@ -475,7 +478,7 @@ def test_coroutine(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autodata_NewType_module_level(app):
|
||||
def test_autodata_NewType_module_level(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'class', 'target.typevar.T6')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -490,7 +493,7 @@ def test_autodata_NewType_module_level(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autoattribute_NewType_class_level(app):
|
||||
def test_autoattribute_NewType_class_level(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'class', 'target.typevar.Class.T6')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -505,7 +508,7 @@ def test_autoattribute_NewType_class_level(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autodata_TypeVar_class_level(app):
|
||||
def test_autodata_TypeVar_class_level(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'class', 'target.typevar.T1')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -520,7 +523,7 @@ def test_autodata_TypeVar_class_level(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autoattribute_TypeVar_module_level(app):
|
||||
def test_autoattribute_TypeVar_module_level(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'class', 'target.typevar.Class.T1')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -535,7 +538,7 @@ def test_autoattribute_TypeVar_module_level(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_inherited_instance_variable_with_annotations(app):
|
||||
def test_inherited_instance_variable_with_annotations(app: SphinxTestApp) -> None:
|
||||
options = {
|
||||
'members': None,
|
||||
'inherited-members': None,
|
||||
@ -566,7 +569,7 @@ def test_inherited_instance_variable_with_annotations(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_no_inherited_instance_variable_with_annotations(app):
|
||||
def test_no_inherited_instance_variable_with_annotations(app: SphinxTestApp) -> None:
|
||||
options = {'members': None}
|
||||
actual = do_autodoc(
|
||||
app, 'class', 'target.inherited_annotations.NoTypeAnnotation2', options
|
||||
|
@ -10,6 +10,8 @@ from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
from tests.test_extensions.autodoc_util import do_autodoc
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
@ -11,13 +11,15 @@ from typing import TYPE_CHECKING
|
||||
if TYPE_CHECKING:
|
||||
from typing import Any
|
||||
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.test_extensions.autodoc_util import do_autodoc
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_classes(app):
|
||||
def test_classes(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'function', 'target.classes.Foo')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -52,7 +54,7 @@ def test_classes(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_callable(app):
|
||||
def test_callable(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'function', 'target.callable.function')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -65,7 +67,7 @@ def test_callable(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_method(app):
|
||||
def test_method(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'function', 'target.callable.method')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -78,7 +80,7 @@ def test_method(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_builtin_function(app):
|
||||
def test_builtin_function(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'function', 'os.umask')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -91,7 +93,7 @@ def test_builtin_function(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_methoddescriptor(app):
|
||||
def test_methoddescriptor(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'function', 'builtins.int.__add__')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -104,7 +106,7 @@ def test_methoddescriptor(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_decorated(app):
|
||||
def test_decorated(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'function', 'target.decorator.foo')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -115,7 +117,7 @@ def test_decorated(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_singledispatch(app):
|
||||
def test_singledispatch(app: SphinxTestApp) -> None:
|
||||
options: dict[str, Any] = {}
|
||||
actual = do_autodoc(app, 'function', 'target.singledispatch.func', options)
|
||||
assert list(actual) == [
|
||||
@ -133,7 +135,7 @@ def test_singledispatch(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_cfunction(app):
|
||||
def test_cfunction(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'function', 'time.asctime')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -148,7 +150,7 @@ def test_cfunction(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_wrapped_function(app):
|
||||
def test_wrapped_function(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'function', 'target.wrappedfunction.slow_function')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -161,7 +163,7 @@ def test_wrapped_function(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_wrapped_function_contextmanager(app):
|
||||
def test_wrapped_function_contextmanager(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'function', 'target.wrappedfunction.feeling_good')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -174,7 +176,7 @@ def test_wrapped_function_contextmanager(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_coroutine(app):
|
||||
def test_coroutine(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'function', 'target.functions.coroutinefunc')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -186,7 +188,7 @@ def test_coroutine(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_synchronized_coroutine(app):
|
||||
def test_synchronized_coroutine(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'function', 'target.coroutine.sync_func')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -197,7 +199,7 @@ def test_synchronized_coroutine(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_async_generator(app):
|
||||
def test_async_generator(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'function', 'target.functions.asyncgenerator')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -209,7 +211,7 @@ def test_async_generator(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_slice_function_arg(app):
|
||||
def test_slice_function_arg(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'function', 'target.functions.slice_arg_func')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
|
@ -14,9 +14,12 @@ import pytest
|
||||
|
||||
from tests.test_extensions.autodoc_util import do_autodoc
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_empty_all(app):
|
||||
def test_empty_all(app: SphinxTestApp) -> None:
|
||||
options = {'members': None}
|
||||
actual = do_autodoc(app, 'module', 'target.empty_all', options)
|
||||
assert list(actual) == [
|
||||
@ -29,7 +32,7 @@ def test_empty_all(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_automodule(app):
|
||||
def test_automodule(app: SphinxTestApp) -> None:
|
||||
options = {'members': None}
|
||||
actual = do_autodoc(app, 'module', 'target.module', options)
|
||||
assert list(actual) == [
|
||||
@ -54,7 +57,7 @@ def test_automodule(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_automodule_undoc_members(app):
|
||||
def test_automodule_undoc_members(app: SphinxTestApp) -> None:
|
||||
options = {
|
||||
'members': None,
|
||||
'undoc-members': None,
|
||||
@ -87,7 +90,7 @@ def test_automodule_undoc_members(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_automodule_special_members(app):
|
||||
def test_automodule_special_members(app: SphinxTestApp) -> None:
|
||||
options = {
|
||||
'members': None,
|
||||
'special-members': None,
|
||||
@ -122,7 +125,7 @@ def test_automodule_special_members(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_automodule_inherited_members(app):
|
||||
def test_automodule_inherited_members(app: SphinxTestApp) -> None:
|
||||
options = {
|
||||
'members': None,
|
||||
'undoc-members': None,
|
||||
@ -217,7 +220,7 @@ def test_automodule_inherited_members(app):
|
||||
},
|
||||
)
|
||||
@pytest.mark.usefixtures('rollback_sysmodules')
|
||||
def test_subclass_of_mocked_object(app):
|
||||
def test_subclass_of_mocked_object(app: SphinxTestApp) -> None:
|
||||
from sphinx.ext.autodoc.mock import _MockObject
|
||||
|
||||
sys.modules.pop('target', None) # unload target module to clear the module cache
|
||||
|
@ -6,13 +6,18 @@ source file translated by test_build.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.test_extensions.autodoc_util import do_autodoc
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_properties(app):
|
||||
def test_properties(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'property', 'target.properties.Foo.prop1')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -26,7 +31,7 @@ def test_properties(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_class_properties(app):
|
||||
def test_class_properties(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'property', 'target.properties.Foo.prop2')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -41,7 +46,7 @@ def test_class_properties(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_properties_with_type_comment(app):
|
||||
def test_properties_with_type_comment(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(
|
||||
app, 'property', 'target.properties.Foo.prop1_with_type_comment'
|
||||
)
|
||||
@ -57,7 +62,7 @@ def test_properties_with_type_comment(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_class_properties_with_type_comment(app):
|
||||
def test_class_properties_with_type_comment(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(
|
||||
app, 'property', 'target.properties.Foo.prop2_with_type_comment'
|
||||
)
|
||||
@ -74,7 +79,7 @@ def test_class_properties_with_type_comment(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_cached_properties(app):
|
||||
def test_cached_properties(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(app, 'property', 'target.cached_property.Foo.prop')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -86,7 +91,7 @@ def test_cached_properties(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_cached_properties_with_type_comment(app):
|
||||
def test_cached_properties_with_type_comment(app: SphinxTestApp) -> None:
|
||||
actual = do_autodoc(
|
||||
app, 'property', 'target.cached_property.Foo.prop_with_type_comment'
|
||||
)
|
||||
|
@ -17,6 +17,8 @@ if TYPE_CHECKING:
|
||||
from collections.abc import Iterator
|
||||
from pathlib import Path
|
||||
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
IS_PYPY = platform.python_implementation() == 'PyPy'
|
||||
|
||||
|
||||
@ -34,7 +36,7 @@ def overwrite_file(path: Path, content: str) -> Iterator[None]:
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autoclass_content_class(app):
|
||||
def test_autoclass_content_class(app: SphinxTestApp) -> None:
|
||||
app.config.autoclass_content = 'class'
|
||||
options = {'members': None}
|
||||
actual = do_autodoc(app, 'module', 'target.autoclass_content', options)
|
||||
@ -94,7 +96,7 @@ def test_autoclass_content_class(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autoclass_content_init(app):
|
||||
def test_autoclass_content_init(app: SphinxTestApp) -> None:
|
||||
app.config.autoclass_content = 'init'
|
||||
options = {'members': None}
|
||||
actual = do_autodoc(app, 'module', 'target.autoclass_content', options)
|
||||
@ -154,7 +156,7 @@ def test_autoclass_content_init(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autodoc_class_signature_mixed(app):
|
||||
def test_autodoc_class_signature_mixed(app: SphinxTestApp) -> None:
|
||||
app.config.autodoc_class_signature = 'mixed'
|
||||
options = {
|
||||
'members': None,
|
||||
@ -170,7 +172,7 @@ def test_autodoc_class_signature_mixed(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autodoc_class_signature_separated_init(app):
|
||||
def test_autodoc_class_signature_separated_init(app: SphinxTestApp) -> None:
|
||||
app.config.autodoc_class_signature = 'separated'
|
||||
options = {
|
||||
'members': None,
|
||||
@ -190,7 +192,7 @@ def test_autodoc_class_signature_separated_init(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autodoc_class_signature_separated_new(app):
|
||||
def test_autodoc_class_signature_separated_new(app: SphinxTestApp) -> None:
|
||||
app.config.autodoc_class_signature = 'separated'
|
||||
options = {
|
||||
'members': None,
|
||||
@ -211,7 +213,7 @@ def test_autodoc_class_signature_separated_new(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autoclass_content_both(app):
|
||||
def test_autoclass_content_both(app: SphinxTestApp) -> None:
|
||||
app.config.autoclass_content = 'both'
|
||||
options = {'members': None}
|
||||
actual = do_autodoc(app, 'module', 'target.autoclass_content', options)
|
||||
@ -281,7 +283,7 @@ def test_autoclass_content_both(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autodoc_inherit_docstrings(app):
|
||||
def test_autodoc_inherit_docstrings(app: SphinxTestApp) -> None:
|
||||
assert app.config.autodoc_inherit_docstrings is True # default
|
||||
actual = do_autodoc(app, 'method', 'target.inheritance.Derived.inheritedmeth')
|
||||
assert list(actual) == [
|
||||
@ -305,7 +307,7 @@ def test_autodoc_inherit_docstrings(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autodoc_inherit_docstrings_for_inherited_members(app):
|
||||
def test_autodoc_inherit_docstrings_for_inherited_members(app: SphinxTestApp) -> None:
|
||||
options = {
|
||||
'members': None,
|
||||
'inherited-members': None,
|
||||
@ -385,7 +387,7 @@ def test_autodoc_inherit_docstrings_for_inherited_members(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autodoc_docstring_signature(app):
|
||||
def test_autodoc_docstring_signature(app: SphinxTestApp) -> None:
|
||||
options = {'members': None, 'special-members': '__init__, __new__'}
|
||||
actual = do_autodoc(app, 'class', 'target.DocstringSig', options)
|
||||
assert list(actual) == [
|
||||
@ -508,7 +510,7 @@ def test_autodoc_docstring_signature(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autoclass_content_and_docstring_signature_class(app):
|
||||
def test_autoclass_content_and_docstring_signature_class(app: SphinxTestApp) -> None:
|
||||
app.config.autoclass_content = 'class'
|
||||
options = {
|
||||
'members': None,
|
||||
@ -547,7 +549,7 @@ def test_autoclass_content_and_docstring_signature_class(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autoclass_content_and_docstring_signature_init(app):
|
||||
def test_autoclass_content_and_docstring_signature_init(app: SphinxTestApp) -> None:
|
||||
app.config.autoclass_content = 'init'
|
||||
options = {
|
||||
'members': None,
|
||||
@ -590,7 +592,7 @@ def test_autoclass_content_and_docstring_signature_init(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autoclass_content_and_docstring_signature_both(app):
|
||||
def test_autoclass_content_and_docstring_signature_both(app: SphinxTestApp) -> None:
|
||||
app.config.autoclass_content = 'both'
|
||||
options = {
|
||||
'members': None,
|
||||
@ -638,7 +640,7 @@ 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):
|
||||
def test_mocked_module_imports(app: SphinxTestApp) -> None:
|
||||
sys.modules.pop('target', None) # unload target module to clear the module cache
|
||||
|
||||
# no autodoc_mock_imports
|
||||
@ -707,7 +709,7 @@ def test_mocked_module_imports(app):
|
||||
testroot='ext-autodoc',
|
||||
confoverrides={'autodoc_typehints': 'signature'},
|
||||
)
|
||||
def test_autodoc_typehints_signature(app):
|
||||
def test_autodoc_typehints_signature(app: SphinxTestApp) -> None:
|
||||
options = {
|
||||
'members': None,
|
||||
'undoc-members': None,
|
||||
@ -834,7 +836,7 @@ def test_autodoc_typehints_signature(app):
|
||||
testroot='ext-autodoc',
|
||||
confoverrides={'autodoc_typehints': 'none'},
|
||||
)
|
||||
def test_autodoc_typehints_none(app):
|
||||
def test_autodoc_typehints_none(app: SphinxTestApp) -> None:
|
||||
options = {
|
||||
'members': None,
|
||||
'undoc-members': None,
|
||||
@ -952,7 +954,7 @@ def test_autodoc_typehints_none(app):
|
||||
testroot='ext-autodoc',
|
||||
confoverrides={'autodoc_typehints': 'none'},
|
||||
)
|
||||
def test_autodoc_typehints_none_for_overload(app):
|
||||
def test_autodoc_typehints_none_for_overload(app: SphinxTestApp) -> None:
|
||||
options = {'members': None}
|
||||
actual = do_autodoc(app, 'module', 'target.overload', options)
|
||||
assert list(actual) == [
|
||||
@ -1004,7 +1006,7 @@ def test_autodoc_typehints_none_for_overload(app):
|
||||
confoverrides={'autodoc_typehints': 'description'},
|
||||
freshenv=True,
|
||||
)
|
||||
def test_autodoc_typehints_description(app):
|
||||
def test_autodoc_typehints_description(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
context = (app.outdir / 'index.txt').read_text(encoding='utf8')
|
||||
assert (
|
||||
@ -1047,7 +1049,7 @@ def test_autodoc_typehints_description(app):
|
||||
},
|
||||
copy_test_root=True,
|
||||
)
|
||||
def test_autodoc_typehints_description_no_undoc(app):
|
||||
def test_autodoc_typehints_description_no_undoc(app: SphinxTestApp) -> None:
|
||||
# No :type: or :rtype: will be injected for `incr`, which does not have
|
||||
# a description for its parameters or its return. `tuple_args` does
|
||||
# describe them, so :type: and :rtype: will be added.
|
||||
@ -1100,7 +1102,7 @@ def test_autodoc_typehints_description_no_undoc(app):
|
||||
},
|
||||
copy_test_root=True,
|
||||
)
|
||||
def test_autodoc_typehints_description_no_undoc_doc_rtype(app):
|
||||
def test_autodoc_typehints_description_no_undoc_doc_rtype(app: SphinxTestApp) -> None:
|
||||
# No :type: will be injected for `incr`, which does not have a description
|
||||
# for its parameters or its return, just :rtype: will be injected due to
|
||||
# autodoc_typehints_description_target. `tuple_args` does describe both, so
|
||||
@ -1170,7 +1172,7 @@ def test_autodoc_typehints_description_no_undoc_doc_rtype(app):
|
||||
confoverrides={'autodoc_typehints': 'description'},
|
||||
copy_test_root=True,
|
||||
)
|
||||
def test_autodoc_typehints_description_with_documented_init(app):
|
||||
def test_autodoc_typehints_description_with_documented_init(app: SphinxTestApp) -> None:
|
||||
with overwrite_file(
|
||||
app.srcdir / 'index.rst',
|
||||
'.. autoclass:: target.typehints._ClassWithDocumentedInit\n'
|
||||
@ -1215,7 +1217,9 @@ def test_autodoc_typehints_description_with_documented_init(app):
|
||||
},
|
||||
copy_test_root=True,
|
||||
)
|
||||
def test_autodoc_typehints_description_with_documented_init_no_undoc(app):
|
||||
def test_autodoc_typehints_description_with_documented_init_no_undoc(
|
||||
app: SphinxTestApp,
|
||||
) -> None:
|
||||
with overwrite_file(
|
||||
app.srcdir / 'index.rst',
|
||||
'.. autoclass:: target.typehints._ClassWithDocumentedInit\n'
|
||||
@ -1250,7 +1254,9 @@ def test_autodoc_typehints_description_with_documented_init_no_undoc(app):
|
||||
},
|
||||
copy_test_root=True,
|
||||
)
|
||||
def test_autodoc_typehints_description_with_documented_init_no_undoc_doc_rtype(app):
|
||||
def test_autodoc_typehints_description_with_documented_init_no_undoc_doc_rtype(
|
||||
app: SphinxTestApp,
|
||||
) -> None:
|
||||
# see test_autodoc_typehints_description_with_documented_init_no_undoc
|
||||
# returnvalue_and_documented_params should not change class or method
|
||||
# docstring.
|
||||
@ -1284,7 +1290,7 @@ def test_autodoc_typehints_description_with_documented_init_no_undoc_doc_rtype(a
|
||||
testroot='ext-autodoc',
|
||||
confoverrides={'autodoc_typehints': 'description'},
|
||||
)
|
||||
def test_autodoc_typehints_description_for_invalid_node(app):
|
||||
def test_autodoc_typehints_description_for_invalid_node(app: SphinxTestApp) -> None:
|
||||
text = '.. py:function:: hello; world'
|
||||
restructuredtext.parse(app, text) # raises no error
|
||||
|
||||
@ -1295,7 +1301,7 @@ def test_autodoc_typehints_description_for_invalid_node(app):
|
||||
confoverrides={'autodoc_typehints': 'both'},
|
||||
copy_test_root=True,
|
||||
)
|
||||
def test_autodoc_typehints_both(app):
|
||||
def test_autodoc_typehints_both(app: SphinxTestApp) -> None:
|
||||
with overwrite_file(
|
||||
app.srcdir / 'index.rst',
|
||||
'.. autofunction:: target.typehints.incr\n'
|
||||
@ -1338,7 +1344,7 @@ def test_autodoc_typehints_both(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('text', testroot='ext-autodoc')
|
||||
def test_autodoc_type_aliases(app):
|
||||
def test_autodoc_type_aliases(app: SphinxTestApp) -> None:
|
||||
# default
|
||||
options = {'members': None}
|
||||
actual = do_autodoc(app, 'module', 'target.autodoc_type_aliases', options)
|
||||
@ -1492,7 +1498,7 @@ def test_autodoc_type_aliases(app):
|
||||
'autodoc_type_aliases': {'myint': 'myint'},
|
||||
},
|
||||
)
|
||||
def test_autodoc_typehints_description_and_type_aliases(app):
|
||||
def test_autodoc_typehints_description_and_type_aliases(app: SphinxTestApp) -> None:
|
||||
with overwrite_file(
|
||||
app.srcdir / 'autodoc_type_aliases.rst',
|
||||
'.. autofunction:: target.autodoc_type_aliases.sum',
|
||||
@ -1519,7 +1525,7 @@ def test_autodoc_typehints_description_and_type_aliases(app):
|
||||
testroot='ext-autodoc',
|
||||
confoverrides={'autodoc_typehints_format': 'fully-qualified'},
|
||||
)
|
||||
def test_autodoc_typehints_format_fully_qualified(app):
|
||||
def test_autodoc_typehints_format_fully_qualified(app: SphinxTestApp) -> None:
|
||||
options = {
|
||||
'members': None,
|
||||
'undoc-members': None,
|
||||
@ -1646,7 +1652,9 @@ def test_autodoc_typehints_format_fully_qualified(app):
|
||||
testroot='ext-autodoc',
|
||||
confoverrides={'autodoc_typehints_format': 'fully-qualified'},
|
||||
)
|
||||
def test_autodoc_typehints_format_fully_qualified_for_class_alias(app):
|
||||
def test_autodoc_typehints_format_fully_qualified_for_class_alias(
|
||||
app: SphinxTestApp,
|
||||
) -> None:
|
||||
actual = do_autodoc(app, 'class', 'target.classes.Alias')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -1662,7 +1670,9 @@ def test_autodoc_typehints_format_fully_qualified_for_class_alias(app):
|
||||
testroot='ext-autodoc',
|
||||
confoverrides={'autodoc_typehints_format': 'fully-qualified'},
|
||||
)
|
||||
def test_autodoc_typehints_format_fully_qualified_for_generic_alias(app):
|
||||
def test_autodoc_typehints_format_fully_qualified_for_generic_alias(
|
||||
app: SphinxTestApp,
|
||||
) -> None:
|
||||
actual = do_autodoc(app, 'data', 'target.genericalias.L')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -1681,7 +1691,9 @@ def test_autodoc_typehints_format_fully_qualified_for_generic_alias(app):
|
||||
testroot='ext-autodoc',
|
||||
confoverrides={'autodoc_typehints_format': 'fully-qualified'},
|
||||
)
|
||||
def test_autodoc_typehints_format_fully_qualified_for_newtype_alias(app):
|
||||
def test_autodoc_typehints_format_fully_qualified_for_newtype_alias(
|
||||
app: SphinxTestApp,
|
||||
) -> None:
|
||||
actual = do_autodoc(app, 'class', 'target.typevar.T6')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@ -1696,7 +1708,7 @@ def test_autodoc_typehints_format_fully_qualified_for_newtype_alias(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autodoc_default_options(app):
|
||||
def test_autodoc_default_options(app: SphinxTestApp) -> None:
|
||||
if (3, 11, 7) <= sys.version_info < (3, 12) or sys.version_info >= (3, 12, 1):
|
||||
list_of_weak_references = ' list of weak references to the object'
|
||||
else:
|
||||
@ -1775,7 +1787,7 @@ def test_autodoc_default_options(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autodoc_default_options_with_values(app):
|
||||
def test_autodoc_default_options_with_values(app: SphinxTestApp) -> None:
|
||||
if (3, 11, 7) <= sys.version_info < (3, 12) or sys.version_info >= (3, 12, 1):
|
||||
list_of_weak_references = ' list of weak references to the object'
|
||||
else:
|
||||
|
@ -2,15 +2,20 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
from sphinx.ext.autodoc import between, cut_lines
|
||||
|
||||
from tests.test_extensions.autodoc_util import do_autodoc
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_process_docstring(app):
|
||||
def test_process_docstring(app: SphinxTestApp) -> None:
|
||||
def on_process_docstring(app, what, name, obj, options, lines):
|
||||
lines.clear()
|
||||
lines.append('my docstring')
|
||||
@ -29,7 +34,7 @@ def test_process_docstring(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_process_docstring_for_nondatadescriptor(app):
|
||||
def test_process_docstring_for_nondatadescriptor(app: SphinxTestApp) -> None:
|
||||
def on_process_docstring(app, what, name, obj, options, lines):
|
||||
raise RuntimeError
|
||||
|
||||
@ -46,7 +51,7 @@ def test_process_docstring_for_nondatadescriptor(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_cut_lines(app):
|
||||
def test_cut_lines(app: SphinxTestApp) -> None:
|
||||
app.connect('autodoc-process-docstring', cut_lines(2, 2, ['function']))
|
||||
|
||||
actual = do_autodoc(app, 'function', 'target.process_docstring.func')
|
||||
@ -81,7 +86,7 @@ def test_cut_lines_no_objtype():
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_between(app):
|
||||
def test_between(app: SphinxTestApp) -> None:
|
||||
app.connect('autodoc-process-docstring', between('---', ['function']))
|
||||
|
||||
actual = do_autodoc(app, 'function', 'target.process_docstring.func')
|
||||
@ -96,7 +101,7 @@ def test_between(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_between_exclude(app):
|
||||
def test_between_exclude(app: SphinxTestApp) -> None:
|
||||
app.connect('autodoc-process-docstring', between('---', ['function'], exclude=True))
|
||||
|
||||
actual = do_autodoc(app, 'function', 'target.process_docstring.func')
|
||||
@ -112,7 +117,7 @@ def test_between_exclude(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_skip_module_member(app):
|
||||
def test_skip_module_member(app: SphinxTestApp) -> None:
|
||||
def autodoc_skip_member(app, what, name, obj, skip, options):
|
||||
if name == 'Class':
|
||||
return True # Skip "Class" class in __all__
|
||||
|
@ -2,17 +2,22 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.test_extensions.autodoc_util import do_autodoc
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
'html',
|
||||
testroot='ext-autodoc',
|
||||
confoverrides={'autodoc_preserve_defaults': True},
|
||||
)
|
||||
def test_preserve_defaults(app):
|
||||
def test_preserve_defaults(app: SphinxTestApp) -> None:
|
||||
color = '0xFFFFFF'
|
||||
|
||||
options = {'members': None}
|
||||
@ -102,7 +107,7 @@ def test_preserve_defaults(app):
|
||||
testroot='ext-autodoc',
|
||||
confoverrides={'autodoc_preserve_defaults': True},
|
||||
)
|
||||
def test_preserve_defaults_special_constructs(app):
|
||||
def test_preserve_defaults_special_constructs(app: SphinxTestApp) -> None:
|
||||
options = {'members': None}
|
||||
actual = do_autodoc(
|
||||
app, 'module', 'target.preserve_defaults_special_constructs', options
|
||||
|
@ -2,13 +2,18 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.test_extensions.autodoc_util import do_autodoc
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_private_field(app):
|
||||
def test_private_field(app: SphinxTestApp) -> None:
|
||||
app.config.autoclass_content = 'class'
|
||||
options = {'members': None}
|
||||
actual = do_autodoc(app, 'module', 'target.private', options)
|
||||
@ -35,7 +40,7 @@ def test_private_field(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_private_field_and_private_members(app):
|
||||
def test_private_field_and_private_members(app: SphinxTestApp) -> None:
|
||||
app.config.autoclass_content = 'class'
|
||||
options = {
|
||||
'members': None,
|
||||
@ -80,7 +85,7 @@ def test_private_field_and_private_members(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_private_members(app):
|
||||
def test_private_members(app: SphinxTestApp) -> None:
|
||||
app.config.autoclass_content = 'class'
|
||||
options = {
|
||||
'members': None,
|
||||
@ -110,7 +115,7 @@ def test_private_members(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_private_attributes(app):
|
||||
def test_private_attributes(app: SphinxTestApp) -> None:
|
||||
app.config.autoclass_content = 'class'
|
||||
options = {'members': None}
|
||||
actual = do_autodoc(app, 'class', 'target.private.Foo', options)
|
||||
@ -132,7 +137,7 @@ def test_private_attributes(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_private_attributes_and_private_members(app):
|
||||
def test_private_attributes_and_private_members(app: SphinxTestApp) -> None:
|
||||
app.config.autoclass_content = 'class'
|
||||
options = {
|
||||
'members': None,
|
||||
|
@ -3,12 +3,16 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autosectionlabel')
|
||||
def test_autosectionlabel_html(app):
|
||||
def test_autosectionlabel_html(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -61,7 +65,7 @@ def test_autosectionlabel_html(app):
|
||||
|
||||
# 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):
|
||||
def test_autosectionlabel_prefix_document_html(app: SphinxTestApp) -> None:
|
||||
test_autosectionlabel_html(app)
|
||||
|
||||
|
||||
@ -70,7 +74,7 @@ def test_autosectionlabel_prefix_document_html(app):
|
||||
testroot='ext-autosectionlabel',
|
||||
confoverrides={'autosectionlabel_maxdepth': 3},
|
||||
)
|
||||
def test_autosectionlabel_maxdepth(app):
|
||||
def test_autosectionlabel_maxdepth(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
from docutils import nodes
|
||||
|
||||
@ -9,6 +11,9 @@ from sphinx import addnodes
|
||||
from sphinx.ext.autosummary import autosummary_table
|
||||
from sphinx.testing.util import assert_node
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='ext-autosummary-import_cycle')
|
||||
@pytest.mark.usefixtures('rollback_sysmodules')
|
||||
@ -65,7 +70,7 @@ def test_autosummary_import_cycle(app):
|
||||
copy_test_root=True,
|
||||
)
|
||||
@pytest.mark.usefixtures('rollback_sysmodules')
|
||||
def test_autosummary_generate_prefixes(app):
|
||||
def test_autosummary_generate_prefixes(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
warnings = app.warning.getvalue()
|
||||
assert 'Summarised items should not include the current module.' not in warnings
|
||||
|
@ -3,12 +3,16 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import pickle
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('coverage', testroot='root')
|
||||
def test_build(app):
|
||||
def test_build(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
py_undoc = (app.outdir / 'python.txt').read_text(encoding='utf8')
|
||||
@ -52,7 +56,7 @@ def test_build(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('coverage', testroot='ext-coverage')
|
||||
def test_coverage_ignore_pyobjects(app):
|
||||
def test_coverage_ignore_pyobjects(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
actual = (app.outdir / 'python.txt').read_text(encoding='utf8')
|
||||
expected = """\
|
||||
@ -97,7 +101,7 @@ Classes:
|
||||
@pytest.mark.sphinx(
|
||||
'coverage', testroot='root', confoverrides={'coverage_show_missing_items': True}
|
||||
)
|
||||
def test_show_missing_items(app):
|
||||
def test_show_missing_items(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
assert 'undocumented' in app.status.getvalue()
|
||||
@ -112,7 +116,7 @@ def test_show_missing_items(app):
|
||||
@pytest.mark.sphinx(
|
||||
'coverage', testroot='root', confoverrides={'coverage_show_missing_items': True}
|
||||
)
|
||||
def test_show_missing_items_quiet(app):
|
||||
def test_show_missing_items_quiet(app: SphinxTestApp) -> None:
|
||||
app.quiet = True
|
||||
app.build(force_all=True)
|
||||
|
||||
|
@ -4,6 +4,7 @@ from __future__ import annotations
|
||||
|
||||
import os
|
||||
from collections import Counter
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
from docutils import nodes
|
||||
@ -12,11 +13,14 @@ from packaging.version import InvalidVersion
|
||||
|
||||
from sphinx.ext.doctest import is_allowed_version
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
cleanup_called = 0
|
||||
|
||||
|
||||
@pytest.mark.sphinx('doctest', testroot='ext-doctest')
|
||||
def test_build(app):
|
||||
def test_build(app: SphinxTestApp) -> None:
|
||||
global cleanup_called # NoQA: PLW0603
|
||||
cleanup_called = 0
|
||||
app.build(force_all=True)
|
||||
@ -27,7 +31,7 @@ def test_build(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='ext-doctest')
|
||||
def test_highlight_language_default(app):
|
||||
def test_highlight_language_default(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
doctree = app.env.get_doctree('doctest')
|
||||
for node in doctree.findall(nodes.literal_block):
|
||||
@ -39,7 +43,7 @@ def test_highlight_language_default(app):
|
||||
testroot='ext-doctest',
|
||||
confoverrides={'highlight_language': 'python'},
|
||||
)
|
||||
def test_highlight_language_python3(app):
|
||||
def test_highlight_language_python3(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
doctree = app.env.get_doctree('doctest')
|
||||
for node in doctree.findall(nodes.literal_block):
|
||||
@ -79,7 +83,7 @@ recorded_calls: Counter[tuple[str, str, int]] = Counter()
|
||||
|
||||
|
||||
@pytest.mark.sphinx('doctest', testroot='ext-doctest-skipif')
|
||||
def test_skipif(app):
|
||||
def test_skipif(app: SphinxTestApp) -> None:
|
||||
"""Tests for the :skipif: option
|
||||
|
||||
The tests are separated into a different test root directory since the
|
||||
|
@ -3,16 +3,20 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
'dummy',
|
||||
testroot='basic',
|
||||
confoverrides={'extensions': ['sphinx.ext.duration']},
|
||||
)
|
||||
def test_githubpages(app):
|
||||
def test_githubpages(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
assert 'slowest reading durations' in app.status.getvalue()
|
||||
|
@ -1,20 +1,25 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
'html',
|
||||
testroot='ext-extlinks-hardcoded-urls',
|
||||
confoverrides={'extlinks_detect_hardcoded_links': False},
|
||||
)
|
||||
def test_extlinks_detect_candidates(app):
|
||||
def test_extlinks_detect_candidates(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
assert app.warning.getvalue() == ''
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-extlinks-hardcoded-urls')
|
||||
def test_replaceable_uris_emit_extlinks_warnings(app):
|
||||
def test_replaceable_uris_emit_extlinks_warnings(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
warning_output = app.warning.getvalue()
|
||||
|
||||
@ -32,7 +37,9 @@ def test_replaceable_uris_emit_extlinks_warnings(app):
|
||||
'html',
|
||||
testroot='ext-extlinks-hardcoded-urls-multiple-replacements',
|
||||
)
|
||||
def test_all_replacements_suggested_if_multiple_replacements_possible(app):
|
||||
def test_all_replacements_suggested_if_multiple_replacements_possible(
|
||||
app: SphinxTestApp,
|
||||
) -> None:
|
||||
app.build()
|
||||
warning_output = app.warning.getvalue()
|
||||
# there should be six warnings for replaceable URLs, three pairs per link
|
||||
|
@ -6,6 +6,8 @@ from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
@ -4,15 +4,19 @@ from __future__ import annotations
|
||||
|
||||
import re
|
||||
import sys
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
from sphinx.ext.graphviz import ClickableMapDefinition
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-graphviz')
|
||||
@pytest.mark.usefixtures('if_graphviz_found')
|
||||
def test_graphviz_png_html(app):
|
||||
def test_graphviz_png_html(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -56,7 +60,7 @@ def test_graphviz_png_html(app):
|
||||
confoverrides={'graphviz_output_format': 'svg'},
|
||||
)
|
||||
@pytest.mark.usefixtures('if_graphviz_found')
|
||||
def test_graphviz_svg_html(app):
|
||||
def test_graphviz_svg_html(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -123,7 +127,7 @@ def test_graphviz_svg_html(app):
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='ext-graphviz')
|
||||
@pytest.mark.usefixtures('if_graphviz_found')
|
||||
def test_graphviz_latex(app):
|
||||
def test_graphviz_latex(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
@ -151,7 +155,7 @@ def test_graphviz_latex(app):
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-graphviz', confoverrides={'language': 'xx'})
|
||||
@pytest.mark.usefixtures('if_graphviz_found')
|
||||
def test_graphviz_i18n(app):
|
||||
def test_graphviz_i18n(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
|
@ -2,15 +2,20 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import docutils.utils
|
||||
import pytest
|
||||
|
||||
from sphinx import addnodes
|
||||
from sphinx.testing import restructuredtext
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('text', testroot='ext-ifconfig')
|
||||
def test_ifconfig(app):
|
||||
def test_ifconfig(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'index.txt').read_text(encoding='utf8')
|
||||
assert 'spam' in result
|
||||
@ -18,7 +23,7 @@ def test_ifconfig(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='_blank')
|
||||
def test_ifconfig_content_line_number(app):
|
||||
def test_ifconfig_content_line_number(app: SphinxTestApp) -> None:
|
||||
app.setup_extension('sphinx.ext.ifconfig')
|
||||
text = '.. ifconfig:: confval1\n\n Some link here: :ref:`abc`\n'
|
||||
doc = restructuredtext.parse(app, text)
|
||||
|
@ -3,9 +3,13 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import subprocess
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def _if_converter_found(app):
|
||||
@ -27,7 +31,7 @@ def _if_converter_found(app):
|
||||
|
||||
@pytest.mark.usefixtures('_if_converter_found')
|
||||
@pytest.mark.sphinx('latex', testroot='ext-imgconverter')
|
||||
def test_ext_imgconverter(app):
|
||||
def test_ext_imgconverter(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
|
@ -2,11 +2,16 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='ext-imgmockconverter')
|
||||
def test_ext_imgmockconverter(app):
|
||||
def test_ext_imgmockconverter(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
|
@ -6,6 +6,7 @@ import re
|
||||
import sys
|
||||
import zlib
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
@ -16,10 +17,13 @@ from sphinx.ext.inheritance_diagram import (
|
||||
)
|
||||
from sphinx.ext.intersphinx._load import load_mappings, validate_intersphinx_mapping
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='inheritance')
|
||||
@pytest.mark.usefixtures('if_graphviz_found')
|
||||
def test_inheritance_diagram(app):
|
||||
def test_inheritance_diagram(app: SphinxTestApp) -> None:
|
||||
# monkey-patch InheritaceDiagram.run() so we can get access to its
|
||||
# results.
|
||||
orig_run = InheritanceDiagram.run
|
||||
@ -32,12 +36,12 @@ def test_inheritance_diagram(app):
|
||||
graphs[source] = node['graph']
|
||||
return result
|
||||
|
||||
InheritanceDiagram.run = new_run
|
||||
InheritanceDiagram.run = new_run # type: ignore[method-assign]
|
||||
|
||||
try:
|
||||
app.build(force_all=True)
|
||||
finally:
|
||||
InheritanceDiagram.run = orig_run
|
||||
InheritanceDiagram.run = orig_run # type: ignore[method-assign]
|
||||
|
||||
assert app.statuscode == 0
|
||||
|
||||
@ -266,7 +270,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):
|
||||
def test_inheritance_diagram_latex(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
|
@ -41,6 +41,7 @@ if TYPE_CHECKING:
|
||||
from typing import NoReturn
|
||||
|
||||
from sphinx.ext.intersphinx._shared import InventoryCacheEntry
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
from sphinx.util.typing import Inventory
|
||||
|
||||
|
||||
@ -507,7 +508,7 @@ def test_inventory_not_having_version(tmp_path, app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root')
|
||||
def test_validate_intersphinx_mapping_warnings(app):
|
||||
def test_validate_intersphinx_mapping_warnings(app: SphinxTestApp) -> None:
|
||||
"""Check warnings in :func:`sphinx.ext.intersphinx.validate_intersphinx_mapping`."""
|
||||
bad_intersphinx_mapping = {
|
||||
'': ('789.example', None), # invalid project name (value)
|
||||
@ -698,7 +699,7 @@ def test_inspect_main_url(capsys):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-intersphinx-role', copy_test_root=True)
|
||||
def test_intersphinx_role(app):
|
||||
def test_intersphinx_role(app: SphinxTestApp) -> None:
|
||||
inv_file = app.srcdir / 'inventory'
|
||||
inv_file.write_bytes(INVENTORY_V2)
|
||||
app.config.intersphinx_mapping = {
|
||||
|
@ -6,6 +6,7 @@ import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import warnings
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
from docutils import nodes
|
||||
@ -13,6 +14,9 @@ from docutils import nodes
|
||||
from sphinx.ext.mathjax import MATHJAX_URL
|
||||
from sphinx.testing.util import assert_node
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
def has_binary(binary: str) -> bool:
|
||||
try:
|
||||
@ -33,7 +37,7 @@ def has_binary(binary: str) -> bool:
|
||||
testroot='ext-math-simple',
|
||||
confoverrides={'extensions': ['sphinx.ext.imgmath']},
|
||||
)
|
||||
def test_imgmath_png(app):
|
||||
def test_imgmath_png(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
if "LaTeX command 'latex' cannot be run" in app.warning.getvalue():
|
||||
msg = 'LaTeX command "latex" is not available'
|
||||
@ -60,7 +64,7 @@ def test_imgmath_png(app):
|
||||
testroot='ext-math-simple',
|
||||
confoverrides={'extensions': ['sphinx.ext.imgmath'], 'imgmath_image_format': 'svg'},
|
||||
)
|
||||
def test_imgmath_svg(app):
|
||||
def test_imgmath_svg(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
if "LaTeX command 'latex' cannot be run" in app.warning.getvalue():
|
||||
msg = 'LaTeX command "latex" is not available'
|
||||
@ -91,7 +95,7 @@ def test_imgmath_svg(app):
|
||||
'imgmath_embed': True,
|
||||
},
|
||||
)
|
||||
def test_imgmath_svg_embed(app):
|
||||
def test_imgmath_svg_embed(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
if "LaTeX command 'latex' cannot be run" in app.warning.getvalue():
|
||||
msg = 'LaTeX command "latex" is not available'
|
||||
@ -114,7 +118,7 @@ def test_imgmath_svg_embed(app):
|
||||
'mathjax_options': {'integrity': 'sha384-0123456789'},
|
||||
},
|
||||
)
|
||||
def test_mathjax_options(app):
|
||||
def test_mathjax_options(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -131,7 +135,7 @@ def test_mathjax_options(app):
|
||||
testroot='ext-math',
|
||||
confoverrides={'extensions': ['sphinx.ext.mathjax']},
|
||||
)
|
||||
def test_mathjax_align(app):
|
||||
def test_mathjax_align(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -149,7 +153,7 @@ def test_mathjax_align(app):
|
||||
testroot='ext-math',
|
||||
confoverrides={'math_number_all': True, 'extensions': ['sphinx.ext.mathjax']},
|
||||
)
|
||||
def test_math_number_all_mathjax(app):
|
||||
def test_math_number_all_mathjax(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -165,7 +169,7 @@ def test_math_number_all_mathjax(app):
|
||||
testroot='ext-math',
|
||||
confoverrides={'extensions': ['sphinx.ext.mathjax']},
|
||||
)
|
||||
def test_math_number_all_latex(app):
|
||||
def test_math_number_all_latex(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
@ -206,7 +210,7 @@ def test_math_number_all_latex(app):
|
||||
'math_eqref_format': 'Eq.{number}',
|
||||
},
|
||||
)
|
||||
def test_math_eqref_format_html(app):
|
||||
def test_math_eqref_format_html(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'math.html').read_text(encoding='utf8')
|
||||
@ -226,7 +230,7 @@ def test_math_eqref_format_html(app):
|
||||
'math_eqref_format': 'Eq.{number}',
|
||||
},
|
||||
)
|
||||
def test_math_eqref_format_latex(app):
|
||||
def test_math_eqref_format_latex(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
@ -246,7 +250,7 @@ def test_math_eqref_format_latex(app):
|
||||
'math_numfig': True,
|
||||
},
|
||||
)
|
||||
def test_mathjax_numfig_html(app):
|
||||
def test_mathjax_numfig_html(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'math.html').read_text(encoding='utf8')
|
||||
@ -273,7 +277,7 @@ def test_mathjax_numfig_html(app):
|
||||
'math_numsep': '-',
|
||||
},
|
||||
)
|
||||
def test_mathjax_numsep_html(app):
|
||||
def test_mathjax_numsep_html(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'math.html').read_text(encoding='utf8')
|
||||
@ -301,7 +305,7 @@ def test_mathjax_numsep_html(app):
|
||||
'math_numfig': True,
|
||||
},
|
||||
)
|
||||
def test_imgmath_numfig_html(app):
|
||||
def test_imgmath_numfig_html(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'page.html').read_text(encoding='utf8')
|
||||
@ -363,7 +367,7 @@ def test_math_compat(app):
|
||||
'mathjax3_config': {'extensions': ['tex2jax.js']},
|
||||
},
|
||||
)
|
||||
def test_mathjax3_config(app):
|
||||
def test_mathjax3_config(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -380,7 +384,7 @@ def test_mathjax3_config(app):
|
||||
'mathjax2_config': {'extensions': ['tex2jax.js']},
|
||||
},
|
||||
)
|
||||
def test_mathjax2_config(app):
|
||||
def test_mathjax2_config(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -401,7 +405,7 @@ def test_mathjax2_config(app):
|
||||
'mathjax3_config': {'extensions': ['tex2jax.js']},
|
||||
},
|
||||
)
|
||||
def test_mathjax_options_async_for_mathjax3(app):
|
||||
def test_mathjax_options_async_for_mathjax3(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -418,7 +422,7 @@ def test_mathjax_options_async_for_mathjax3(app):
|
||||
'mathjax2_config': {'extensions': ['tex2jax.js']},
|
||||
},
|
||||
)
|
||||
def test_mathjax_options_defer_for_mathjax2(app):
|
||||
def test_mathjax_options_defer_for_mathjax2(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -433,7 +437,7 @@ def test_mathjax_options_defer_for_mathjax2(app):
|
||||
'mathjax_path': 'MathJax.js',
|
||||
},
|
||||
)
|
||||
def test_mathjax_path(app):
|
||||
def test_mathjax_path(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -448,7 +452,7 @@ def test_mathjax_path(app):
|
||||
'mathjax_path': 'MathJax.js?config=scipy-mathjax',
|
||||
},
|
||||
)
|
||||
def test_mathjax_path_config(app):
|
||||
def test_mathjax_path_config(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -462,7 +466,7 @@ def test_mathjax_path_config(app):
|
||||
testroot='ext-math',
|
||||
confoverrides={'extensions': ['sphinx.ext.mathjax']},
|
||||
)
|
||||
def test_mathjax_is_installed_only_if_document_having_math(app):
|
||||
def test_mathjax_is_installed_only_if_document_having_math(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -477,7 +481,7 @@ def test_mathjax_is_installed_only_if_document_having_math(app):
|
||||
testroot='basic',
|
||||
confoverrides={'extensions': ['sphinx.ext.mathjax']},
|
||||
)
|
||||
def test_mathjax_is_not_installed_if_no_equations(app):
|
||||
def test_mathjax_is_not_installed_if_no_equations(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -489,7 +493,7 @@ def test_mathjax_is_not_installed_if_no_equations(app):
|
||||
testroot='ext-math',
|
||||
confoverrides={'extensions': ['sphinx.ext.mathjax']},
|
||||
)
|
||||
def test_mathjax_is_installed_if_no_equations_when_forced(app):
|
||||
def test_mathjax_is_installed_if_no_equations_when_forced(app: SphinxTestApp) -> None:
|
||||
app.set_html_assets_policy('always')
|
||||
app.build(force_all=True)
|
||||
|
||||
@ -505,7 +509,9 @@ def test_mathjax_is_installed_if_no_equations_when_forced(app):
|
||||
testroot='ext-math-include',
|
||||
confoverrides={'extensions': ['sphinx.ext.mathjax']},
|
||||
)
|
||||
def test_mathjax_is_installed_if_included_file_has_equations(app):
|
||||
def test_mathjax_is_installed_if_included_file_has_equations(
|
||||
app: SphinxTestApp,
|
||||
) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
# no real equations at the rst level, but includes "included"
|
||||
@ -525,7 +531,9 @@ def test_mathjax_is_installed_if_included_file_has_equations(app):
|
||||
testroot='ext-math',
|
||||
confoverrides={'extensions': ['sphinx.ext.mathjax']},
|
||||
)
|
||||
def test_mathjax_is_installed_only_if_document_having_math_singlehtml(app):
|
||||
def test_mathjax_is_installed_only_if_document_having_math_singlehtml(
|
||||
app: SphinxTestApp,
|
||||
) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -537,7 +545,9 @@ def test_mathjax_is_installed_only_if_document_having_math_singlehtml(app):
|
||||
testroot='basic',
|
||||
confoverrides={'extensions': ['sphinx.ext.mathjax']},
|
||||
)
|
||||
def test_mathjax_is_not_installed_if_no_equations_singlehtml(app):
|
||||
def test_mathjax_is_not_installed_if_no_equations_singlehtml(
|
||||
app: SphinxTestApp,
|
||||
) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -549,7 +559,9 @@ def test_mathjax_is_not_installed_if_no_equations_singlehtml(app):
|
||||
testroot='ext-math-include',
|
||||
confoverrides={'extensions': ['sphinx.ext.mathjax']},
|
||||
)
|
||||
def test_mathjax_is_installed_if_included_file_has_equations_singlehtml(app):
|
||||
def test_mathjax_is_installed_if_included_file_has_equations_singlehtml(
|
||||
app: SphinxTestApp,
|
||||
) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
|
@ -8,6 +8,7 @@ from collections import namedtuple
|
||||
from inspect import cleandoc
|
||||
from itertools import product
|
||||
from textwrap import dedent
|
||||
from typing import TYPE_CHECKING
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
@ -27,6 +28,9 @@ from sphinx.testing.util import etree_parse
|
||||
from tests.test_extensions.ext_napoleon_pep526_data_google import PEP526GoogleClass
|
||||
from tests.test_extensions.ext_napoleon_pep526_data_numpy import PEP526NumpyClass
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
class NamedtupleSubclass(namedtuple('NamedtupleSubclass', ('attr1', 'attr2'))): # NoQA: PYI024
|
||||
"""Sample namedtuple subclass
|
||||
@ -2819,7 +2823,7 @@ Sample class with PEP 526 annotations and numpy docstring
|
||||
'autodoc_typehints_description_target': 'all',
|
||||
},
|
||||
)
|
||||
def test_napoleon_and_autodoc_typehints_description_all(app):
|
||||
def test_napoleon_and_autodoc_typehints_description_all(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
content = (app.outdir / 'typehints.txt').read_text(encoding='utf-8')
|
||||
assert content == (
|
||||
@ -2848,7 +2852,9 @@ def test_napoleon_and_autodoc_typehints_description_all(app):
|
||||
'autodoc_typehints_description_target': 'documented_params',
|
||||
},
|
||||
)
|
||||
def test_napoleon_and_autodoc_typehints_description_documented_params(app):
|
||||
def test_napoleon_and_autodoc_typehints_description_documented_params(
|
||||
app: SphinxTestApp,
|
||||
) -> None:
|
||||
app.build()
|
||||
content = (app.outdir / 'typehints.txt').read_text(encoding='utf-8')
|
||||
assert content == (
|
||||
|
@ -3,9 +3,13 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
'html',
|
||||
@ -13,7 +17,7 @@ import pytest
|
||||
freshenv=True,
|
||||
confoverrides={'todo_include_todos': True, 'todo_emit_warnings': True},
|
||||
)
|
||||
def test_todo(app):
|
||||
def test_todo(app: SphinxTestApp) -> None:
|
||||
todos = []
|
||||
|
||||
def on_todo_defined(app, node):
|
||||
@ -55,7 +59,7 @@ def test_todo(app):
|
||||
freshenv=True,
|
||||
confoverrides={'todo_include_todos': False, 'todo_emit_warnings': True},
|
||||
)
|
||||
def test_todo_not_included(app):
|
||||
def test_todo_not_included(app: SphinxTestApp) -> None:
|
||||
todos = []
|
||||
|
||||
def on_todo_defined(app, node):
|
||||
@ -93,7 +97,7 @@ def test_todo_not_included(app):
|
||||
freshenv=True,
|
||||
confoverrides={'todo_include_todos': True},
|
||||
)
|
||||
def test_todo_valid_link(app):
|
||||
def test_todo_valid_link(app: SphinxTestApp) -> None:
|
||||
"""Test that the inserted "original entry" links for todo items have a target
|
||||
that exists in the LaTeX output. The target was previously incorrectly omitted.
|
||||
https://github.com/sphinx-doc/sphinx/issues/1020
|
||||
|
@ -9,6 +9,8 @@ from typing import TYPE_CHECKING
|
||||
import pygments
|
||||
import pytest
|
||||
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
@ -63,7 +65,7 @@ def check_viewcode_output(app: SphinxTestApp) -> str:
|
||||
confoverrides={'viewcode_line_numbers': True},
|
||||
)
|
||||
@pytest.mark.usefixtures('rollback_sysmodules')
|
||||
def test_viewcode_linenos(app):
|
||||
def test_viewcode_linenos(app: SphinxTestApp) -> None:
|
||||
shutil.rmtree(app.outdir / '_modules', ignore_errors=True)
|
||||
app.build(force_all=True)
|
||||
|
||||
@ -78,7 +80,7 @@ def test_viewcode_linenos(app):
|
||||
confoverrides={'viewcode_line_numbers': False},
|
||||
)
|
||||
@pytest.mark.usefixtures('rollback_sysmodules')
|
||||
def test_viewcode(app):
|
||||
def test_viewcode(app: SphinxTestApp) -> None:
|
||||
shutil.rmtree(app.outdir / '_modules', ignore_errors=True)
|
||||
app.build(force_all=True)
|
||||
|
||||
@ -88,7 +90,7 @@ def test_viewcode(app):
|
||||
|
||||
@pytest.mark.sphinx('epub', testroot='ext-viewcode')
|
||||
@pytest.mark.usefixtures('rollback_sysmodules')
|
||||
def test_viewcode_epub_default(app):
|
||||
def test_viewcode_epub_default(app: SphinxTestApp) -> None:
|
||||
shutil.rmtree(app.outdir)
|
||||
app.build(force_all=True)
|
||||
|
||||
@ -104,7 +106,7 @@ def test_viewcode_epub_default(app):
|
||||
confoverrides={'viewcode_enable_epub': True},
|
||||
)
|
||||
@pytest.mark.usefixtures('rollback_sysmodules')
|
||||
def test_viewcode_epub_enabled(app):
|
||||
def test_viewcode_epub_enabled(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
assert (app.outdir / '_modules/spam/mod1.xhtml').exists()
|
||||
@ -114,7 +116,7 @@ def test_viewcode_epub_enabled(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-viewcode', tags=['test_linkcode'])
|
||||
def test_linkcode(app):
|
||||
def test_linkcode(app: SphinxTestApp) -> None:
|
||||
app.build(filenames=[app.srcdir / 'objects.rst'])
|
||||
|
||||
stuff = (app.outdir / 'objects.html').read_text(encoding='utf8')
|
||||
@ -127,7 +129,7 @@ def test_linkcode(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-viewcode-find', freshenv=True)
|
||||
def test_local_source_files(app):
|
||||
def test_local_source_files(app: SphinxTestApp) -> None:
|
||||
def find_source(app, modname):
|
||||
if modname == 'not_a_package':
|
||||
source = app.srcdir / 'not_a_package/__init__.py'
|
||||
|
@ -2,14 +2,19 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
from sphinx.errors import VersionRequirementError
|
||||
from sphinx.extension import Extension, verify_needs_extensions
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root')
|
||||
def test_needs_extensions(app):
|
||||
def test_needs_extensions(app: SphinxTestApp) -> None:
|
||||
# empty needs_extensions
|
||||
assert app.config.needs_extensions == {}
|
||||
verify_needs_extensions(app, app.config)
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
from unittest import mock
|
||||
|
||||
import pygments
|
||||
@ -12,6 +13,9 @@ from pygments.token import Name, Text
|
||||
|
||||
from sphinx.highlighting import PygmentsBridge
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
if tuple(map(int, pygments.__version__.split('.')[:2])) < (2, 18):
|
||||
from pygments.formatter import Formatter
|
||||
|
||||
@ -41,7 +45,7 @@ class ComplainOnUnhighlighted(PygmentsBridge):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root')
|
||||
def test_add_lexer(app):
|
||||
def test_add_lexer(app: SphinxTestApp) -> None:
|
||||
app.add_lexer('test', MyLexer)
|
||||
|
||||
bridge = PygmentsBridge('html')
|
||||
|
@ -4,9 +4,13 @@ from __future__ import annotations
|
||||
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def _setup_test(app_params):
|
||||
@ -37,7 +41,7 @@ def _setup_test(app_params):
|
||||
testroot='intl',
|
||||
confoverrides={'language': 'en', 'locale_dirs': ['./locale']},
|
||||
)
|
||||
def test_compile_all_catalogs(app):
|
||||
def test_compile_all_catalogs(app: SphinxTestApp) -> None:
|
||||
app.builder.compile_all_catalogs()
|
||||
|
||||
locale_dir = app.srcdir / 'locale'
|
||||
@ -55,7 +59,7 @@ def test_compile_all_catalogs(app):
|
||||
testroot='intl',
|
||||
confoverrides={'language': 'en', 'locale_dirs': ['./locale']},
|
||||
)
|
||||
def test_compile_specific_catalogs(app):
|
||||
def test_compile_specific_catalogs(app: SphinxTestApp) -> None:
|
||||
locale_dir = app.srcdir / 'locale'
|
||||
catalog_dir = locale_dir / app.config.language / 'LC_MESSAGES'
|
||||
|
||||
@ -76,7 +80,7 @@ def test_compile_specific_catalogs(app):
|
||||
testroot='intl',
|
||||
confoverrides={'language': 'en', 'locale_dirs': ['./locale']},
|
||||
)
|
||||
def test_compile_update_catalogs(app):
|
||||
def test_compile_update_catalogs(app: SphinxTestApp) -> None:
|
||||
app.builder.compile_update_catalogs()
|
||||
|
||||
locale_dir = app.srcdir / 'locale'
|
||||
|
@ -4,11 +4,16 @@
|
||||
# https://docutils.sourceforge.io/docs/user/rst/demo.txt
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='metadata')
|
||||
def test_docinfo(app):
|
||||
def test_docinfo(app: SphinxTestApp) -> None:
|
||||
"""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
|
||||
that might be considered document metadata, such as 'abstract' or
|
||||
|
@ -2,17 +2,22 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
from sphinx.testing.util import etree_parse
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
'html',
|
||||
testroot='smartquotes',
|
||||
freshenv=True,
|
||||
)
|
||||
def test_basic(app):
|
||||
def test_basic(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -24,7 +29,7 @@ def test_basic(app):
|
||||
testroot='smartquotes',
|
||||
freshenv=True,
|
||||
)
|
||||
def test_literals(app):
|
||||
def test_literals(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
etree = etree_parse(app.outdir / 'literals.html')
|
||||
@ -44,7 +49,7 @@ def test_literals(app):
|
||||
testroot='smartquotes',
|
||||
freshenv=True,
|
||||
)
|
||||
def test_text_builder(app):
|
||||
def test_text_builder(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'index.txt').read_text(encoding='utf8')
|
||||
@ -56,7 +61,7 @@ def test_text_builder(app):
|
||||
testroot='smartquotes',
|
||||
freshenv=True,
|
||||
)
|
||||
def test_man_builder(app):
|
||||
def test_man_builder(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'projectnamenotset.1').read_text(encoding='utf8')
|
||||
@ -68,7 +73,7 @@ def test_man_builder(app):
|
||||
testroot='smartquotes',
|
||||
freshenv=True,
|
||||
)
|
||||
def test_latex_builder(app):
|
||||
def test_latex_builder(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
@ -81,7 +86,7 @@ def test_latex_builder(app):
|
||||
freshenv=True,
|
||||
confoverrides={'language': 'ja'},
|
||||
)
|
||||
def test_ja_html_builder(app):
|
||||
def test_ja_html_builder(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -94,7 +99,7 @@ def test_ja_html_builder(app):
|
||||
freshenv=True,
|
||||
confoverrides={'language': 'zh_CN'},
|
||||
)
|
||||
def test_zh_cn_html_builder(app):
|
||||
def test_zh_cn_html_builder(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -107,7 +112,7 @@ def test_zh_cn_html_builder(app):
|
||||
freshenv=True,
|
||||
confoverrides={'language': 'zh_TW'},
|
||||
)
|
||||
def test_zh_tw_html_builder(app):
|
||||
def test_zh_tw_html_builder(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -120,7 +125,7 @@ def test_zh_tw_html_builder(app):
|
||||
freshenv=True,
|
||||
confoverrides={'smartquotes': False},
|
||||
)
|
||||
def test_smartquotes_disabled(app):
|
||||
def test_smartquotes_disabled(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -133,7 +138,7 @@ def test_smartquotes_disabled(app):
|
||||
freshenv=True,
|
||||
confoverrides={'smartquotes_action': 'q'},
|
||||
)
|
||||
def test_smartquotes_action(app):
|
||||
def test_smartquotes_action(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -146,7 +151,7 @@ def test_smartquotes_action(app):
|
||||
freshenv=True,
|
||||
confoverrides={'language': 'ja', 'smartquotes_excludes': {}},
|
||||
)
|
||||
def test_smartquotes_excludes_language(app):
|
||||
def test_smartquotes_excludes_language(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -159,7 +164,7 @@ def test_smartquotes_excludes_language(app):
|
||||
freshenv=True,
|
||||
confoverrides={'smartquotes_excludes': {}},
|
||||
)
|
||||
def test_smartquotes_excludes_builders(app):
|
||||
def test_smartquotes_excludes_builders(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
content = (app.outdir / 'projectnamenotset.1').read_text(encoding='utf8')
|
||||
|
@ -3,11 +3,15 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
from sphinx.project import Project
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
DOCNAMES = {
|
||||
'autodoc',
|
||||
'bom',
|
||||
@ -81,7 +85,7 @@ def test_project_path2doc(rootdir):
|
||||
testroot='basic',
|
||||
srcdir='project_doc2path',
|
||||
)
|
||||
def test_project_doc2path(app):
|
||||
def test_project_doc2path(app: SphinxTestApp) -> None:
|
||||
source_suffix = {'.rst': 'restructuredtext', '.txt': 'restructuredtext'}
|
||||
|
||||
project = Project(app.srcdir, source_suffix)
|
||||
|
@ -21,6 +21,7 @@ if TYPE_CHECKING:
|
||||
from typing import Any
|
||||
|
||||
from sphinx.domains import ObjType
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
JAVASCRIPT_TEST_ROOTS = [
|
||||
directory
|
||||
@ -90,7 +91,7 @@ test that non-comments are indexed: fermion
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-viewcode')
|
||||
def test_objects_are_escaped(app):
|
||||
def test_objects_are_escaped(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
index = load_searchindex(app.outdir / 'searchindex.js')
|
||||
for item in index.get('objects').get(''):
|
||||
@ -101,7 +102,7 @@ def test_objects_are_escaped(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='search')
|
||||
def test_meta_keys_are_handled_for_language_en(app):
|
||||
def test_meta_keys_are_handled_for_language_en(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
searchindex = load_searchindex(app.outdir / 'searchindex.js')
|
||||
assert not is_registered_term(searchindex, 'thisnoteith')
|
||||
@ -119,7 +120,7 @@ def test_meta_keys_are_handled_for_language_en(app):
|
||||
confoverrides={'html_search_language': 'de'},
|
||||
freshenv=True,
|
||||
)
|
||||
def test_meta_keys_are_handled_for_language_de(app):
|
||||
def test_meta_keys_are_handled_for_language_de(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
searchindex = load_searchindex(app.outdir / 'searchindex.js')
|
||||
assert not is_registered_term(searchindex, 'thisnoteith')
|
||||
@ -132,14 +133,14 @@ def test_meta_keys_are_handled_for_language_de(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='search')
|
||||
def test_stemmer_does_not_remove_short_words(app):
|
||||
def test_stemmer_does_not_remove_short_words(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
searchindex = (app.outdir / 'searchindex.js').read_text(encoding='utf8')
|
||||
assert 'bat' in searchindex
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='search')
|
||||
def test_stemmer(app):
|
||||
def test_stemmer(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
searchindex = load_searchindex(app.outdir / 'searchindex.js')
|
||||
print(searchindex)
|
||||
@ -148,7 +149,7 @@ def test_stemmer(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='search')
|
||||
def test_term_in_heading_and_section(app):
|
||||
def test_term_in_heading_and_section(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
searchindex = (app.outdir / 'searchindex.js').read_text(encoding='utf8')
|
||||
# if search term is in the title of one doc and in the text of another
|
||||
@ -159,7 +160,7 @@ def test_term_in_heading_and_section(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='search')
|
||||
def test_term_in_raw_directive(app):
|
||||
def test_term_in_raw_directive(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
searchindex = load_searchindex(app.outdir / 'searchindex.js')
|
||||
assert not is_registered_term(searchindex, 'raw')
|
||||
@ -380,7 +381,7 @@ def test_IndexBuilder_lookup():
|
||||
confoverrides={'html_search_language': 'zh'},
|
||||
srcdir='search_zh',
|
||||
)
|
||||
def test_search_index_gen_zh(app):
|
||||
def test_search_index_gen_zh(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
index = load_searchindex(app.outdir / 'searchindex.js')
|
||||
assert 'chinesetest ' not in index['terms']
|
||||
@ -394,7 +395,7 @@ def test_search_index_gen_zh(app):
|
||||
testroot='search',
|
||||
freshenv=True,
|
||||
)
|
||||
def test_nosearch(app):
|
||||
def test_nosearch(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
index = load_searchindex(app.outdir / 'searchindex.js')
|
||||
assert index['docnames'] == ['index', 'nosearch', 'tocitem']
|
||||
@ -414,14 +415,14 @@ def test_nosearch(app):
|
||||
parallel=3,
|
||||
freshenv=True,
|
||||
)
|
||||
def test_parallel(app):
|
||||
def test_parallel(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
index = load_searchindex(app.outdir / 'searchindex.js')
|
||||
assert index['docnames'] == ['index', 'nosearch', 'tocitem']
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='search')
|
||||
def test_search_index_is_deterministic(app):
|
||||
def test_search_index_is_deterministic(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
index = load_searchindex(app.outdir / 'searchindex.js')
|
||||
# Pretty print the index. Only shown by pytest on failure.
|
||||
|
@ -1,10 +1,15 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='theming')
|
||||
def test_theme_options(app):
|
||||
def test_theme_options(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
result = (app.outdir / '_static' / 'documentation_options.js').read_text(
|
||||
@ -22,7 +27,7 @@ def test_theme_options(app):
|
||||
'html_theme_options.enable_search_shortcuts': False,
|
||||
},
|
||||
)
|
||||
def test_theme_options_with_override(app):
|
||||
def test_theme_options_with_override(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
result = (app.outdir / '_static' / 'documentation_options.js').read_text(
|
||||
@ -33,7 +38,7 @@ def test_theme_options_with_override(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='build-html-theme-having-multiple-stylesheets')
|
||||
def test_theme_having_multiple_stylesheets(app):
|
||||
def test_theme_having_multiple_stylesheets(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf-8')
|
||||
|
||||
|
@ -4,12 +4,14 @@ from __future__ import annotations
|
||||
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING
|
||||
from xml.etree.ElementTree import ParseError
|
||||
|
||||
import pytest
|
||||
from defusedxml.ElementTree import parse as xml_parse
|
||||
|
||||
import sphinx.builders.html
|
||||
from sphinx.builders.html import StandaloneHTMLBuilder
|
||||
from sphinx.errors import ThemeError
|
||||
from sphinx.theming import (
|
||||
_ConfigFile,
|
||||
@ -20,6 +22,9 @@ from sphinx.theming import (
|
||||
_load_theme_toml,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
HERE = Path(__file__).resolve().parent
|
||||
|
||||
|
||||
@ -28,7 +33,8 @@ HERE = Path(__file__).resolve().parent
|
||||
testroot='theming',
|
||||
confoverrides={'html_theme': 'ziptheme', 'html_theme_options.testopt': 'foo'},
|
||||
)
|
||||
def test_theme_api(app):
|
||||
def test_theme_api(app: SphinxTestApp) -> None:
|
||||
assert isinstance(app.builder, StandaloneHTMLBuilder) # type-checking
|
||||
themes = [
|
||||
'basic',
|
||||
'default',
|
||||
@ -100,7 +106,8 @@ def test_nonexistent_theme_settings(tmp_path):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='double-inheriting-theme')
|
||||
def test_double_inheriting_theme(app):
|
||||
def test_double_inheriting_theme(app: SphinxTestApp) -> None:
|
||||
assert isinstance(app.builder, StandaloneHTMLBuilder) # type-checking
|
||||
assert app.builder.theme.name == 'base_theme2'
|
||||
app.build() # => not raises TemplateNotFound
|
||||
|
||||
@ -110,7 +117,8 @@ def test_double_inheriting_theme(app):
|
||||
testroot='theming',
|
||||
confoverrides={'html_theme': 'child'},
|
||||
)
|
||||
def test_nested_zipped_theme(app):
|
||||
def test_nested_zipped_theme(app: SphinxTestApp) -> None:
|
||||
assert isinstance(app.builder, StandaloneHTMLBuilder) # type-checking
|
||||
assert app.builder.theme.name == 'child'
|
||||
app.build() # => not raises TemplateNotFound
|
||||
|
||||
@ -120,7 +128,7 @@ def test_nested_zipped_theme(app):
|
||||
testroot='theming',
|
||||
confoverrides={'html_theme': 'staticfiles'},
|
||||
)
|
||||
def test_staticfiles(app):
|
||||
def test_staticfiles(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
assert (app.outdir / '_static' / 'legacytmpl.html').exists()
|
||||
assert (app.outdir / '_static' / 'legacytmpl.html').read_text(encoding='utf8') == (
|
||||
@ -174,7 +182,7 @@ def test_dark_style(app, monkeypatch):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='theming')
|
||||
def test_theme_sidebars(app):
|
||||
def test_theme_sidebars(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
# test-theme specifies globaltoc and searchbox as default sidebars
|
||||
|
@ -10,7 +10,7 @@ from docutils import nodes
|
||||
|
||||
from sphinx import addnodes
|
||||
from sphinx.addnodes import SIG_ELEMENTS
|
||||
from sphinx.testing.util import assert_node
|
||||
from sphinx.testing.util import SphinxTestApp, assert_node
|
||||
from sphinx.transforms.post_transforms import SigElementFallbackTransform
|
||||
from sphinx.util.docutils import new_document
|
||||
|
||||
@ -23,7 +23,7 @@ if TYPE_CHECKING:
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='transforms-post_transforms-missing-reference')
|
||||
def test_nitpicky_warning(app):
|
||||
def test_nitpicky_warning(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
assert (
|
||||
'index.rst:4: WARNING: py:class reference target not found: io.StringIO'
|
||||
@ -41,7 +41,7 @@ def test_nitpicky_warning(app):
|
||||
testroot='transforms-post_transforms-missing-reference',
|
||||
freshenv=True,
|
||||
)
|
||||
def test_missing_reference(app):
|
||||
def test_missing_reference(app: SphinxTestApp) -> None:
|
||||
def missing_reference(app_, env_, node_, contnode_):
|
||||
assert app_ is app
|
||||
assert env_ is app.env
|
||||
@ -64,7 +64,7 @@ def test_missing_reference(app):
|
||||
testroot='domain-py-python_use_unqualified_type_names',
|
||||
freshenv=True,
|
||||
)
|
||||
def test_missing_reference_conditional_pending_xref(app):
|
||||
def test_missing_reference_conditional_pending_xref(app: SphinxTestApp) -> None:
|
||||
def missing_reference(_app, _env, _node, contnode):
|
||||
return contnode
|
||||
|
||||
@ -82,7 +82,7 @@ def test_missing_reference_conditional_pending_xref(app):
|
||||
testroot='transforms-post_transforms-keyboard',
|
||||
freshenv=True,
|
||||
)
|
||||
def test_keyboard_hyphen_spaces(app):
|
||||
def test_keyboard_hyphen_spaces(app: SphinxTestApp) -> None:
|
||||
# https://github.com/sphinx-doc/sphinx/issues/10495
|
||||
app.build()
|
||||
assert 'spanish' in (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
|
@ -1,10 +1,15 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='trim_doctest_flags')
|
||||
def test_trim_doctest_flags_html(app):
|
||||
def test_trim_doctest_flags_html(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -24,7 +29,7 @@ def test_trim_doctest_flags_html(app):
|
||||
testroot='trim_doctest_flags',
|
||||
confoverrides={'trim_doctest_flags': False},
|
||||
)
|
||||
def test_trim_doctest_flags_disabled(app):
|
||||
def test_trim_doctest_flags_disabled(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@ -38,7 +43,7 @@ def test_trim_doctest_flags_disabled(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='trim_doctest_flags')
|
||||
def test_trim_doctest_flags_latex(app):
|
||||
def test_trim_doctest_flags_latex(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
|
||||
result = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
from docutils import nodes
|
||||
|
||||
@ -9,9 +11,14 @@ from sphinx import addnodes
|
||||
from sphinx.testing import restructuredtext
|
||||
from sphinx.testing.util import assert_node
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='_blank')
|
||||
def test_transforms_reorder_consecutive_target_and_index_nodes_preserve_order(app):
|
||||
def test_transforms_reorder_consecutive_target_and_index_nodes_preserve_order(
|
||||
app: SphinxTestApp,
|
||||
) -> None:
|
||||
text = '.. index:: abc\n.. index:: def\n.. index:: ghi\n.. index:: jkl\n\ntext\n'
|
||||
doctree = restructuredtext.parse(app, text)
|
||||
assert_node(
|
||||
@ -99,7 +106,9 @@ def test_transforms_reorder_consecutive_target_and_index_nodes_no_merge_across_o
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='_blank')
|
||||
def test_transforms_reorder_consecutive_target_and_index_nodes_merge_with_labels(app):
|
||||
def test_transforms_reorder_consecutive_target_and_index_nodes_merge_with_labels(
|
||||
app: SphinxTestApp,
|
||||
) -> None:
|
||||
text = (
|
||||
'.. _abc:\n'
|
||||
'.. index:: def\n'
|
||||
|
@ -5,6 +5,7 @@ from __future__ import annotations
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from sphinx._cli.util.errors import strip_escape_sequences
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from pathlib import Path
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
from sphinx._cli.util.errors import strip_escape_sequences
|
||||
@ -13,6 +15,9 @@ from sphinx.util.display import (
|
||||
status_iterator,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
def test_display_chunk() -> None:
|
||||
assert display_chunk('hello') == 'hello'
|
||||
@ -23,7 +28,7 @@ def test_display_chunk() -> None:
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='root')
|
||||
def test_status_iterator_length_0(app):
|
||||
def test_status_iterator_length_0(app: SphinxTestApp) -> None:
|
||||
logging.setup(app, app.status, app.warning)
|
||||
|
||||
# test for status_iterator (length=0)
|
||||
@ -72,7 +77,7 @@ def test_status_iterator_verbosity_1(app, monkeypatch):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root')
|
||||
def test_progress_message(app):
|
||||
def test_progress_message(app: SphinxTestApp) -> None:
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -18,6 +18,7 @@ from sphinx.util.docutils import (
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.builders import Builder
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
def test_register_node() -> None:
|
||||
@ -69,7 +70,7 @@ def test_SphinxFileOutput(tmp_path):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root')
|
||||
def test_SphinxTranslator(app):
|
||||
def test_SphinxTranslator(app: SphinxTestApp) -> None:
|
||||
class CustomNode(nodes.inline):
|
||||
pass
|
||||
|
||||
|
@ -4,6 +4,7 @@ from __future__ import annotations
|
||||
|
||||
import re
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
@ -12,6 +13,9 @@ from sphinx._cli.util.errors import strip_escape_sequences
|
||||
from sphinx.jinja2glue import BuiltinTemplateLoader
|
||||
from sphinx.util.fileutil import _template_basename, copy_asset, copy_asset_file
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
class DummyTemplateLoader(BuiltinTemplateLoader):
|
||||
def __init__(self) -> None:
|
||||
@ -124,7 +128,7 @@ def test_copy_asset(tmp_path):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='html_assets')
|
||||
def test_copy_asset_template(app):
|
||||
def test_copy_asset_template(app: SphinxTestApp) -> None:
|
||||
app.build(force_all=True)
|
||||
|
||||
expected_msg = r'^Writing evaluated template result to [^\n]*\bAPI.html$'
|
||||
@ -133,7 +137,7 @@ def test_copy_asset_template(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='util-copyasset_overwrite')
|
||||
def test_copy_asset_overwrite(app):
|
||||
def test_copy_asset_overwrite(app: SphinxTestApp) -> None:
|
||||
app.build()
|
||||
src = app.srcdir / 'myext_static' / 'custom-styles.css'
|
||||
dst = app.outdir / '_static' / 'custom-styles.css'
|
||||
|
@ -7,6 +7,7 @@ import os
|
||||
import sys
|
||||
import time
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import babel
|
||||
import pytest
|
||||
@ -15,6 +16,9 @@ from babel.messages.mofile import read_mo
|
||||
from sphinx.errors import SphinxError
|
||||
from sphinx.util import i18n
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
def test_catalog_info_for_file_and_path() -> None:
|
||||
cat = i18n.CatalogInfo('path', 'domain', 'utf-8')
|
||||
@ -121,7 +125,7 @@ def test_format_date_timezone() -> None:
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root')
|
||||
def test_get_filename_for_language(app):
|
||||
def test_get_filename_for_language(app: SphinxTestApp) -> None:
|
||||
get_filename = i18n.get_image_filename_for_language
|
||||
app.env.current_document.docname = 'index'
|
||||
|
||||
|
@ -72,7 +72,7 @@ def test_read_inventory_v2_not_having_version() -> None:
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root')
|
||||
def test_ambiguous_definition_warning(app):
|
||||
def test_ambiguous_definition_warning(app: SphinxTestApp) -> None:
|
||||
InventoryFile.loads(INVENTORY_V2_AMBIGUOUS_TERMS, uri='/util')
|
||||
|
||||
def _multiple_defs_notice_for(entity: str) -> str:
|
||||
|
@ -6,6 +6,7 @@ import codecs
|
||||
import os
|
||||
from contextlib import contextmanager
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
from docutils import nodes
|
||||
@ -19,9 +20,12 @@ from sphinx.util.parallel import ParallelTasks
|
||||
|
||||
from tests.utils import TESTS_ROOT
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root')
|
||||
def test_info_and_warning(app):
|
||||
def test_info_and_warning(app: SphinxTestApp) -> None:
|
||||
app.verbosity = 2
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -46,7 +50,7 @@ def test_info_and_warning(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root')
|
||||
def test_Exception(app):
|
||||
def test_Exception(app: SphinxTestApp) -> None:
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -55,7 +59,7 @@ def test_Exception(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root')
|
||||
def test_verbosity_filter(app):
|
||||
def test_verbosity_filter(app: SphinxTestApp) -> None:
|
||||
# verbosity = 0: INFO
|
||||
app.verbosity = 0
|
||||
logging.setup(app, app.status, app.warning)
|
||||
@ -100,7 +104,7 @@ def test_verbosity_filter(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root')
|
||||
def test_nonl_info_log(app):
|
||||
def test_nonl_info_log(app: SphinxTestApp) -> None:
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -112,7 +116,7 @@ def test_nonl_info_log(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root')
|
||||
def test_once_warning_log(app):
|
||||
def test_once_warning_log(app: SphinxTestApp) -> None:
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -139,7 +143,7 @@ def test_is_suppressed_warning():
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root')
|
||||
def test_suppress_warnings(app):
|
||||
def test_suppress_warnings(app: SphinxTestApp) -> None:
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -183,7 +187,7 @@ def test_suppress_warnings(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root')
|
||||
def test_info_location(app):
|
||||
def test_info_location(app: SphinxTestApp) -> None:
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -196,7 +200,7 @@ def test_info_location(app):
|
||||
logger.info('message3', location=None)
|
||||
assert '\nmessage3' in app.status.getvalue()
|
||||
|
||||
node = nodes.Node()
|
||||
node = nodes.Element()
|
||||
node.source, node.line = ('index.txt', 10)
|
||||
logger.info('message4', location=node)
|
||||
assert 'index.txt:10: message4' in app.status.getvalue()
|
||||
@ -215,7 +219,7 @@ def test_info_location(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root')
|
||||
def test_warning_location(app):
|
||||
def test_warning_location(app: SphinxTestApp) -> None:
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -228,7 +232,7 @@ def test_warning_location(app):
|
||||
logger.warning('message3', location=None)
|
||||
assert colorize('red', 'WARNING: message3') in app.warning.getvalue()
|
||||
|
||||
node = nodes.Node()
|
||||
node = nodes.Element()
|
||||
node.source, node.line = ('index.txt', 10)
|
||||
logger.warning('message4', location=node)
|
||||
assert 'index.txt:10: WARNING: message4' in app.warning.getvalue()
|
||||
@ -247,7 +251,7 @@ def test_warning_location(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root')
|
||||
def test_suppress_logging(app):
|
||||
def test_suppress_logging(app: SphinxTestApp) -> None:
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -262,7 +266,7 @@ def test_suppress_logging(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root')
|
||||
def test_pending_warnings(app):
|
||||
def test_pending_warnings(app: SphinxTestApp) -> None:
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -307,7 +311,7 @@ def test_log_no_ansi_colors(tmp_path):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root')
|
||||
def test_colored_logs(app):
|
||||
def test_colored_logs(app: SphinxTestApp) -> None:
|
||||
app.verbosity = 2
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -338,7 +342,7 @@ def test_colored_logs(app):
|
||||
os.name != 'posix',
|
||||
reason='Parallel mode does not work on Windows',
|
||||
)
|
||||
def test_logging_in_ParallelTasks(app):
|
||||
def test_logging_in_ParallelTasks(app: SphinxTestApp) -> None:
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -370,7 +374,7 @@ def test_output_with_unencodable_char(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root')
|
||||
def test_prefixed_warnings(app):
|
||||
def test_prefixed_warnings(app: SphinxTestApp) -> None:
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -396,7 +400,7 @@ def test_get_node_location_abspath():
|
||||
relative_filename = Path('relative', 'path.txt')
|
||||
absolute_filename = relative_filename.resolve()
|
||||
|
||||
n = nodes.Node()
|
||||
n = nodes.Element()
|
||||
n.source = str(relative_filename)
|
||||
|
||||
location = logging.get_node_location(n)
|
||||
@ -405,7 +409,7 @@ def test_get_node_location_abspath():
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root', confoverrides={'show_warning_types': True})
|
||||
def test_show_warning_types(app):
|
||||
def test_show_warning_types(app: SphinxTestApp) -> None:
|
||||
logging.setup(app, app.status, app.warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.warning('message2')
|
||||
|
@ -7,6 +7,8 @@ from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Iterator
|
||||
from pathlib import Path
|
||||
|
Loading…
Reference in New Issue
Block a user