Skip to content

Commit edd2bd3

Browse files
Remove mypy overrides for tests/test_theming/test_theming.py (#14071)
1 parent 95b9b3e commit edd2bd3

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ module = [
243243
"tests.test_markup.test_markup",
244244
# tests/test_theming
245245
"tests.test_theming.test_templating",
246-
"tests.test_theming.test_theming",
247246
]
248247
disallow_untyped_defs = false
249248

tests/test_theming/test_theming.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
)
2424

2525
if TYPE_CHECKING:
26+
from collections.abc import Callable
27+
2628
from sphinx.testing.util import SphinxTestApp
2729

2830
HERE = Path(__file__).resolve().parent
@@ -98,7 +100,7 @@ def test_theme_api(app: SphinxTestApp) -> None:
98100
assert not any(p.exists() for p in theme._tmp_dirs)
99101

100102

101-
def test_nonexistent_theme_settings(tmp_path):
103+
def test_nonexistent_theme_settings(tmp_path: Path) -> None:
102104
# Check that error occurs with a non-existent theme.toml or theme.conf
103105
# https://github.com/sphinx-doc/sphinx/issues/11668
104106
with pytest.raises(ThemeError):
@@ -150,10 +152,12 @@ def test_staticfiles(app: SphinxTestApp) -> None:
150152
testroot='theming',
151153
confoverrides={'html_theme': 'test-theme'},
152154
)
153-
def test_dark_style(app, monkeypatch):
155+
def test_dark_style(app: SphinxTestApp, monkeypatch: pytest.MonkeyPatch) -> None:
154156
monkeypatch.setattr(sphinx.builders.html, '_file_checksum', lambda o, f: '')
155157

156-
style = app.builder.dark_highlighter.formatter_args.get('style')
158+
assert isinstance(app.builder, StandaloneHTMLBuilder)
159+
assert app.builder.dark_highlighter is not None
160+
style = app.builder.dark_highlighter.formatter_args['style']
157161
assert style.__name__ == 'MonokaiStyle'
158162

159163
app.build()
@@ -164,7 +168,7 @@ def test_dark_style(app, monkeypatch):
164168
assert 'media' in css_file.attributes
165169
assert css_file.attributes['media'] == '(prefers-color-scheme: dark)'
166170

167-
assert sorted(f.filename for f in app.builder._css_files) == [
171+
assert sorted(str(f.filename) for f in app.builder._css_files) == [
168172
'_static/classic.css',
169173
'_static/pygments.css',
170174
'_static/pygments_dark.css',
@@ -212,7 +216,12 @@ def test_theme_sidebars(app: SphinxTestApp) -> None:
212216
'traditional',
213217
],
214218
)
215-
def test_theme_builds(make_app, rootdir, sphinx_test_tempdir, theme_name):
219+
def test_theme_builds(
220+
make_app: Callable[..., SphinxTestApp],
221+
rootdir: Path,
222+
sphinx_test_tempdir: Path,
223+
theme_name: str,
224+
) -> None:
216225
"""Test all the themes included with Sphinx build a simple project and produce valid XML."""
217226
testroot_path = rootdir / 'test-basic'
218227
srcdir = sphinx_test_tempdir / f'test-theme-{theme_name}'

0 commit comments

Comments
 (0)