Skip to content

Commit f1fbbfc

Browse files
committed
Add annotations to several single-argument ('app') test functions
1 parent a980fbc commit f1fbbfc

File tree

88 files changed

+870
-496
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+870
-496
lines changed

tests/test_application.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def test_instantiation(
4949

5050

5151
@pytest.mark.sphinx('html', testroot='root')
52-
def test_events(app):
52+
def test_events(app: SphinxTestApp) -> None:
5353
def empty():
5454
pass
5555

@@ -76,27 +76,27 @@ def mock_callback(a_app, *args):
7676

7777

7878
@pytest.mark.sphinx('html', testroot='root')
79-
def test_emit_with_nonascii_name_node(app):
79+
def test_emit_with_nonascii_name_node(app: SphinxTestApp) -> None:
8080
node = nodes.section(names=['\u65e5\u672c\u8a9e'])
8181
app.emit('my_event', node)
8282

8383

8484
@pytest.mark.sphinx('html', testroot='root')
85-
def test_extensions(app):
85+
def test_extensions(app: SphinxTestApp) -> None:
8686
app.setup_extension('shutil')
8787
warning = strip_escape_sequences(app.warning.getvalue())
8888
assert "extension 'shutil' has no setup() function" in warning
8989

9090

9191
@pytest.mark.sphinx('html', testroot='root')
92-
def test_extension_in_blacklist(app):
92+
def test_extension_in_blacklist(app: SphinxTestApp) -> None:
9393
app.setup_extension('sphinxjp.themecore')
9494
msg = strip_escape_sequences(app.warning.getvalue())
9595
assert msg.startswith("WARNING: the extension 'sphinxjp.themecore' was")
9696

9797

9898
@pytest.mark.sphinx('html', testroot='add_source_parser')
99-
def test_add_source_parser(app):
99+
def test_add_source_parser(app: SphinxTestApp) -> None:
100100
assert set(app.config.source_suffix) == {'.rst', '.test'}
101101

102102
# .rst; only in :confval:`source_suffix`
@@ -110,7 +110,7 @@ def test_add_source_parser(app):
110110

111111

112112
@pytest.mark.sphinx('html', testroot='extensions')
113-
def test_add_is_parallel_allowed(app):
113+
def test_add_is_parallel_allowed(app: SphinxTestApp) -> None:
114114
logging.setup(app, app.status, app.warning)
115115

116116
assert app.is_parallel_allowed('read') is True
@@ -155,14 +155,14 @@ def test_add_is_parallel_allowed(app):
155155

156156

157157
@pytest.mark.sphinx('dummy', testroot='root')
158-
def test_build_specific(app):
159-
app.builder.build = Mock()
158+
def test_build_specific(app: SphinxTestApp) -> None:
159+
app.builder.build = Mock() # type: ignore[method-assign,misc]
160160
filenames = [
161161
app.srcdir / 'index.txt', # normal
162162
app.srcdir / 'images', # without suffix
163163
app.srcdir / 'notfound.txt', # not found
164164
app.srcdir / 'img.png', # unknown suffix
165-
'/index.txt', # external file
165+
Path('/index.txt'), # external file
166166
app.srcdir / 'subdir', # directory
167167
app.srcdir / 'subdir/includes.txt', # file on subdir
168168
app.srcdir / 'subdir/../subdir/excluded.txt', # not normalized

tests/test_builders/test_build.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22

33
from __future__ import annotations
44

5+
from typing import TYPE_CHECKING
6+
57
import pytest
68
from docutils import nodes
79

810
from sphinx.errors import SphinxError
911

12+
if TYPE_CHECKING:
13+
from sphinx.testing.util import SphinxTestApp
14+
1015

1116
def test_root_doc_not_found(tmp_path, make_app):
1217
(tmp_path / 'conf.py').touch()
@@ -18,7 +23,7 @@ def test_root_doc_not_found(tmp_path, make_app):
1823

1924

2025
@pytest.mark.sphinx('text', testroot='circular')
21-
def test_circular_toctree(app):
26+
def test_circular_toctree(app: SphinxTestApp) -> None:
2227
app.build(force_all=True)
2328
warnings = app.warning.getvalue()
2429
assert (
@@ -30,7 +35,7 @@ def test_circular_toctree(app):
3035

3136

3237
@pytest.mark.sphinx('text', testroot='numbered-circular')
33-
def test_numbered_circular_toctree(app):
38+
def test_numbered_circular_toctree(app: SphinxTestApp) -> None:
3439
app.build(force_all=True)
3540
warnings = app.warning.getvalue()
3641
assert (
@@ -42,7 +47,7 @@ def test_numbered_circular_toctree(app):
4247

4348

4449
@pytest.mark.sphinx('text', testroot='toctree-multiple-parents')
45-
def test_multiple_parents_toctree(app):
50+
def test_multiple_parents_toctree(app: SphinxTestApp) -> None:
4651
app.build(force_all=True)
4752
assert (
4853
"document is referenced in multiple toctrees: ['bravo', 'delta'], selecting: delta <- charlie"

tests/test_builders/test_build_all.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
import pytest
1414

15+
from sphinx.testing.util import SphinxTestApp
16+
1517
if TYPE_CHECKING:
1618
from collections.abc import Callable
1719
from pathlib import Path

tests/test_builders/test_build_changes.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22

33
from __future__ import annotations
44

5+
from typing import TYPE_CHECKING
6+
57
import pytest
68

9+
if TYPE_CHECKING:
10+
from sphinx.testing.util import SphinxTestApp
11+
712

813
@pytest.mark.sphinx('changes', testroot='changes')
9-
def test_build(app):
14+
def test_build(app: SphinxTestApp) -> None:
1015
app.build()
1116

1217
# TODO: Use better checking of html content
@@ -34,7 +39,7 @@ def test_build(app):
3439
srcdir='changes-none',
3540
confoverrides={'version': '0.7', 'release': '0.7b1'},
3641
)
37-
def test_no_changes(app):
42+
def test_no_changes(app: SphinxTestApp) -> None:
3843
app.build()
3944

4045
assert 'no changes in version 0.7.' in app.status.getvalue()

tests/test_builders/test_build_dirhtml.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@
33
from __future__ import annotations
44

55
import posixpath
6+
from typing import TYPE_CHECKING
67

78
import pytest
89

910
from sphinx.util.inventory import InventoryFile, _InventoryItem
1011

12+
if TYPE_CHECKING:
13+
from sphinx.testing.util import SphinxTestApp
14+
1115

1216
@pytest.mark.sphinx('dirhtml', testroot='builder-dirhtml')
13-
def test_dirhtml(app):
17+
def test_dirhtml(app: SphinxTestApp) -> None:
1418
app.build()
1519

1620
assert (app.outdir / 'index.html').exists()

tests/test_builders/test_build_epub.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import pytest
1313

1414
from sphinx.builders.epub3 import _XML_NAME_PATTERN
15+
from sphinx.testing.util import SphinxTestApp
1516

1617
if TYPE_CHECKING:
1718
from collections.abc import Iterator

tests/test_builders/test_build_gettext.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import pytest
1414

1515
from sphinx.builders.gettext import Catalog, MsgOrigin
16+
from sphinx.testing.util import SphinxTestApp
1617

1718
if TYPE_CHECKING:
1819
from sphinx.testing.util import SphinxTestApp

0 commit comments

Comments
 (0)