diff --git a/sphinx/testing/util.py b/sphinx/testing/util.py index 54c3a6f66e..9cf77d3043 100644 --- a/sphinx/testing/util.py +++ b/sphinx/testing/util.py @@ -178,6 +178,16 @@ class SphinxTestApp(sphinx.application.Sphinx): self.cleanup() raise + def _init_builder(self) -> None: + # override the default theme to 'basic' rather than 'alabaster' + # for test independence + + if 'html_theme' in self.config._overrides: + pass # respect overrides + elif 'html_theme' in self.config and self.config.html_theme == 'alabaster': + self.config.html_theme = self.config._overrides.get('html_theme', 'basic') + super()._init_builder() + @property def status(self) -> StringIO: """The in-memory text I/O for the application status messages.""" diff --git a/tests/test_builders/test_build_html.py b/tests/test_builders/test_build_html.py index 31fc1981dc..2c4601849c 100644 --- a/tests/test_builders/test_build_html.py +++ b/tests/test_builders/test_build_html.py @@ -367,15 +367,12 @@ def test_html_style(app): @pytest.mark.sphinx( 'html', testroot='basic', - # alabaster changed default sidebars in 1.0.0 confoverrides={ 'html_sidebars': { '**': [ - 'about.html', - 'navigation.html', - 'relations.html', - 'searchbox.html', - 'donate.html', + 'localtoc.html', + 'searchfield.html', + 'sourcelink.html', ] } }, @@ -386,45 +383,58 @@ def test_html_sidebar(app): # default for alabaster app.build(force_all=True) result = (app.outdir / 'index.html').read_text(encoding='utf8') + # layout.html assert '