From 5de84c9242643f786eff03726286578726d7d390 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 5 Jun 2024 18:20:59 +0200 Subject: Merging upstream version 7.3.7. Signed-off-by: Daniel Baumann --- tests/test_theming.py | 131 -------------------------------------------------- 1 file changed, 131 deletions(-) delete mode 100644 tests/test_theming.py (limited to 'tests/test_theming.py') diff --git a/tests/test_theming.py b/tests/test_theming.py deleted file mode 100644 index b4c8511..0000000 --- a/tests/test_theming.py +++ /dev/null @@ -1,131 +0,0 @@ -"""Test the Theme class.""" - -import os - -import alabaster -import pytest - -import sphinx.builders.html -from sphinx.theming import ThemeError - - -@pytest.mark.sphinx( - testroot='theming', - confoverrides={'html_theme': 'ziptheme', - 'html_theme_options.testopt': 'foo'}) -def test_theme_api(app, status, warning): - cfg = app.config - - themes = ['basic', 'default', 'scrolls', 'agogo', 'sphinxdoc', 'haiku', - 'traditional', 'epub', 'nature', 'pyramid', 'bizstyle', 'classic', 'nonav', - 'test-theme', 'ziptheme', 'staticfiles', 'parent', 'child'] - try: - alabaster_version = alabaster.__version_info__ - except AttributeError: - alabaster_version = alabaster.version.__version_info__ - if alabaster_version >= (0, 7, 11): - themes.append('alabaster') - - # test Theme class API - assert set(app.registry.html_themes.keys()) == set(themes) - assert app.registry.html_themes['test-theme'] == str(app.srcdir / 'test_theme' / 'test-theme') - assert app.registry.html_themes['ziptheme'] == str(app.srcdir / 'ziptheme.zip') - assert app.registry.html_themes['staticfiles'] == str(app.srcdir / 'test_theme' / 'staticfiles') - - # test Theme instance API - theme = app.builder.theme - assert theme.name == 'ziptheme' - themedir = theme.themedir - assert theme.base.name == 'basic' - assert len(theme.get_theme_dirs()) == 2 - - # direct setting - assert theme.get_config('theme', 'stylesheet') == 'custom.css' - # inherited setting - assert theme.get_config('options', 'nosidebar') == 'false' - # nonexisting setting - assert theme.get_config('theme', 'foobar', 'def') == 'def' - with pytest.raises(ThemeError): - theme.get_config('theme', 'foobar') - - # options API - - options = theme.get_options({'nonexisting': 'foo'}) - assert 'nonexisting' not in options - - options = theme.get_options(cfg.html_theme_options) - assert options['testopt'] == 'foo' - assert options['nosidebar'] == 'false' - - # cleanup temp directories - theme.cleanup() - assert not os.path.exists(themedir) - - -@pytest.mark.sphinx(testroot='double-inheriting-theme') -def test_double_inheriting_theme(app, status, warning): - assert app.builder.theme.name == 'base_theme2' - app.build() # => not raises TemplateNotFound - - -@pytest.mark.sphinx(testroot='theming', - confoverrides={'html_theme': 'child'}) -def test_nested_zipped_theme(app, status, warning): - assert app.builder.theme.name == 'child' - app.build() # => not raises TemplateNotFound - - -@pytest.mark.sphinx(testroot='theming', - confoverrides={'html_theme': 'staticfiles'}) -def test_staticfiles(app, status, warning): - app.build() - assert (app.outdir / '_static' / 'staticimg.png').exists() - assert (app.outdir / '_static' / 'statictmpl.html').exists() - assert (app.outdir / '_static' / 'statictmpl.html').read_text(encoding='utf8') == ( - '\n' - 'Python' - ) - - result = (app.outdir / 'index.html').read_text(encoding='utf8') - assert '' in result - - -@pytest.mark.sphinx(testroot='theming', - confoverrides={'html_theme': 'test-theme'}) -def test_dark_style(app, monkeypatch): - monkeypatch.setattr(sphinx.builders.html, '_file_checksum', lambda o, f: '') - - style = app.builder.dark_highlighter.formatter_args.get('style') - assert style.__name__ == 'MonokaiStyle' - - app.build() - assert (app.outdir / '_static' / 'pygments_dark.css').exists() - - css_file, properties = app.registry.css_files[0] - assert css_file == 'pygments_dark.css' - assert "media" in properties - assert properties["media"] == '(prefers-color-scheme: dark)' - - assert sorted(f.filename for f in app.builder._css_files) == [ - '_static/classic.css', - '_static/pygments.css', - '_static/pygments_dark.css', - ] - - result = (app.outdir / 'index.html').read_text(encoding='utf8') - assert '' in result - assert ('') in result - - -@pytest.mark.sphinx(testroot='theming') -def test_theme_sidebars(app, status, warning): - app.build() - - # test-theme specifies globaltoc and searchbox as default sidebars - result = (app.outdir / 'index.html').read_text(encoding='utf8') - assert '

Table of Contents

' in result - assert '

Related Topics

' not in result - assert '

This Page

' not in result - assert '

Quick search

' in result -- cgit v1.2.3