diff --git a/pyproject.toml b/pyproject.toml index 0d473348afe..0f2f7cec12f 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", ] disallow_untyped_defs = false diff --git a/tests/test_theming/test_theming.py b/tests/test_theming/test_theming.py index 8ff3919c967..0237f5abb59 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,12 @@ 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: '') - style = app.builder.dark_highlighter.formatter_args.get('style') + assert isinstance(app.builder, StandaloneHTMLBuilder) + assert app.builder.dark_highlighter is not None + style = app.builder.dark_highlighter.formatter_args['style'] assert style.__name__ == 'MonokaiStyle' app.build() @@ -164,7 +168,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 +216,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}'