diff --git a/pyproject.toml b/pyproject.toml index 76645abbefe..08479b7b6fc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -287,9 +287,7 @@ module = [ "tests.test_util.test_util_matching", "tests.test_util.test_util_uri", # tests/test_writers - "tests.test_writers.test_api_translator", "tests.test_writers.test_docutilsconf", - "tests.test_writers.test_writer_latex", ] disallow_untyped_defs = false diff --git a/tests/test_writers/test_api_translator.py b/tests/test_writers/test_api_translator.py index cd34aba058a..802ef47530a 100644 --- a/tests/test_writers/test_api_translator.py +++ b/tests/test_writers/test_api_translator.py @@ -3,12 +3,19 @@ from __future__ import annotations import sys +from typing import TYPE_CHECKING import pytest +if TYPE_CHECKING: + from collections.abc import Iterator + from pathlib import Path + + from sphinx.testing.util import SphinxTestApp + @pytest.fixture(scope='module', autouse=True) -def _setup_module(rootdir): +def _setup_module(rootdir: Path) -> Iterator[None]: saved_path = sys.path.copy() sys.path.insert(0, str(rootdir / 'test-api-set-translator')) yield @@ -16,7 +23,7 @@ def _setup_module(rootdir): @pytest.mark.sphinx('html', testroot='root') -def test_html_translator(app): +def test_html_translator(app: SphinxTestApp) -> None: # no set_translator() translator_class = app.builder.get_translator_class() assert translator_class @@ -24,7 +31,7 @@ def test_html_translator(app): @pytest.mark.sphinx('html', testroot='api-set-translator') -def test_html_with_set_translator_for_html_(app): +def test_html_with_set_translator_for_html_(app: SphinxTestApp) -> None: # use set_translator() translator_class = app.builder.get_translator_class() assert translator_class @@ -32,63 +39,63 @@ def test_html_with_set_translator_for_html_(app): @pytest.mark.sphinx('singlehtml', testroot='api-set-translator') -def test_singlehtml_set_translator_for_singlehtml(app): +def test_singlehtml_set_translator_for_singlehtml(app: SphinxTestApp) -> None: translator_class = app.builder.get_translator_class() assert translator_class assert translator_class.__name__ == 'ConfSingleHTMLTranslator' @pytest.mark.sphinx('pickle', testroot='api-set-translator') -def test_pickle_set_translator_for_pickle(app): +def test_pickle_set_translator_for_pickle(app: SphinxTestApp) -> None: translator_class = app.builder.get_translator_class() assert translator_class assert translator_class.__name__ == 'ConfPickleTranslator' @pytest.mark.sphinx('json', testroot='api-set-translator') -def test_json_set_translator_for_json(app): +def test_json_set_translator_for_json(app: SphinxTestApp) -> None: translator_class = app.builder.get_translator_class() assert translator_class assert translator_class.__name__ == 'ConfJsonTranslator' @pytest.mark.sphinx('latex', testroot='api-set-translator') -def test_html_with_set_translator_for_latex(app): +def test_html_with_set_translator_for_latex(app: SphinxTestApp) -> None: translator_class = app.builder.get_translator_class() assert translator_class assert translator_class.__name__ == 'ConfLaTeXTranslator' @pytest.mark.sphinx('man', testroot='api-set-translator') -def test_html_with_set_translator_for_man(app): +def test_html_with_set_translator_for_man(app: SphinxTestApp) -> None: translator_class = app.builder.get_translator_class() assert translator_class assert translator_class.__name__ == 'ConfManualPageTranslator' @pytest.mark.sphinx('texinfo', testroot='api-set-translator') -def test_html_with_set_translator_for_texinfo(app): +def test_html_with_set_translator_for_texinfo(app: SphinxTestApp) -> None: translator_class = app.builder.get_translator_class() assert translator_class assert translator_class.__name__ == 'ConfTexinfoTranslator' @pytest.mark.sphinx('text', testroot='api-set-translator') -def test_html_with_set_translator_for_text(app): +def test_html_with_set_translator_for_text(app: SphinxTestApp) -> None: translator_class = app.builder.get_translator_class() assert translator_class assert translator_class.__name__ == 'ConfTextTranslator' @pytest.mark.sphinx('xml', testroot='api-set-translator') -def test_html_with_set_translator_for_xml(app): +def test_html_with_set_translator_for_xml(app: SphinxTestApp) -> None: translator_class = app.builder.get_translator_class() assert translator_class assert translator_class.__name__ == 'ConfXMLTranslator' @pytest.mark.sphinx('pseudoxml', testroot='api-set-translator') -def test_html_with_set_translator_for_pseudoxml(app): +def test_html_with_set_translator_for_pseudoxml(app: SphinxTestApp) -> None: translator_class = app.builder.get_translator_class() assert translator_class assert translator_class.__name__ == 'ConfPseudoXMLTranslator' diff --git a/tests/test_writers/test_writer_latex.py b/tests/test_writers/test_writer_latex.py index 55130c44d52..bf41e18a5d5 100644 --- a/tests/test_writers/test_writer_latex.py +++ b/tests/test_writers/test_writer_latex.py @@ -7,7 +7,7 @@ from sphinx.writers.latex import rstdim_to_latexdim -def test_rstdim_to_latexdim(): +def test_rstdim_to_latexdim() -> None: # Length units docutils supported # https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#length-units assert rstdim_to_latexdim('160em') == '160em'