From 143f310166d2f279971f369544119e4928fa42bd Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 17 Nov 2025 23:30:03 +0000 Subject: [PATCH] Remove mypy overrides for tests/test_theming/test_theming.py --- pyproject.toml | 1 - tests/test_theming/test_theming.py | 18 ++++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e3418ab98a2..6d3c08ee7f9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -243,7 +243,6 @@ module = [ "tests.test_markup.test_markup", # tests/test_theming "tests.test_theming.test_templating", - "tests.test_theming.test_theming", # tests/test_transforms "tests.test_transforms.test_transforms_post_transforms_images", # tests/test_writers diff --git a/tests/test_theming/test_theming.py b/tests/test_theming/test_theming.py index 8ff3919c967..e316f136db2 100644 --- a/tests/test_theming/test_theming.py +++ b/tests/test_theming/test_theming.py @@ -23,6 +23,8 @@ ) if TYPE_CHECKING: + from collections.abc import Callable + from sphinx.testing.util import SphinxTestApp HERE = Path(__file__).resolve().parent @@ -98,7 +100,7 @@ def test_theme_api(app: SphinxTestApp) -> None: assert not any(p.exists() for p in theme._tmp_dirs) -def test_nonexistent_theme_settings(tmp_path): +def test_nonexistent_theme_settings(tmp_path: Path) -> None: # Check that error occurs with a non-existent theme.toml or theme.conf # https://github.com/sphinx-doc/sphinx/issues/11668 with pytest.raises(ThemeError): @@ -150,10 +152,13 @@ def test_staticfiles(app: SphinxTestApp) -> None: testroot='theming', confoverrides={'html_theme': 'test-theme'}, ) -def test_dark_style(app, monkeypatch): +def test_dark_style(app: SphinxTestApp, monkeypatch: pytest.MonkeyPatch) -> None: monkeypatch.setattr(sphinx.builders.html, '_file_checksum', lambda o, f: '') + assert isinstance(app.builder, StandaloneHTMLBuilder) + assert app.builder.dark_highlighter is not None style = app.builder.dark_highlighter.formatter_args.get('style') + assert style is not None assert style.__name__ == 'MonokaiStyle' app.build() @@ -164,7 +169,7 @@ def test_dark_style(app, monkeypatch): assert 'media' in css_file.attributes assert css_file.attributes['media'] == '(prefers-color-scheme: dark)' - assert sorted(f.filename for f in app.builder._css_files) == [ + assert sorted(str(f.filename) for f in app.builder._css_files) == [ '_static/classic.css', '_static/pygments.css', '_static/pygments_dark.css', @@ -212,7 +217,12 @@ def test_theme_sidebars(app: SphinxTestApp) -> None: 'traditional', ], ) -def test_theme_builds(make_app, rootdir, sphinx_test_tempdir, theme_name): +def test_theme_builds( + make_app: Callable[..., SphinxTestApp], + rootdir: Path, + sphinx_test_tempdir: Path, + theme_name: str, +) -> None: """Test all the themes included with Sphinx build a simple project and produce valid XML.""" testroot_path = rootdir / 'test-basic' srcdir = sphinx_test_tempdir / f'test-theme-{theme_name}'