@@ -184,7 +184,7 @@ def test_primary_logo_is_light_when_no_default_mode(sphinx_build_factory) -> Non
184
184
index_html = sphinx_build .html_tree ("index.html" )
185
185
navbar_brand = index_html .select (".navbar-brand" )[0 ]
186
186
assert navbar_brand .find ("img" , class_ = "only-light" ) is not None
187
- assert navbar_brand .find ("script " , string = re . compile ( "only-dark" ) ) is not None
187
+ assert navbar_brand .find ("img " , class_ = "only-dark" ) is not None
188
188
189
189
190
190
def test_primary_logo_is_light_when_default_mode_is_set_to_auto (
@@ -199,7 +199,7 @@ def test_primary_logo_is_light_when_default_mode_is_set_to_auto(
199
199
index_html = sphinx_build .html_tree ("index.html" )
200
200
navbar_brand = index_html .select (".navbar-brand" )[0 ]
201
201
assert navbar_brand .find ("img" , class_ = "only-light" ) is not None
202
- assert navbar_brand .find ("script " , string = re . compile ( "only-dark" ) ) is not None
202
+ assert navbar_brand .find ("img " , class_ = "only-dark" ) is not None
203
203
204
204
205
205
def test_primary_logo_is_light_when_default_mode_is_light (sphinx_build_factory ) -> None :
@@ -212,7 +212,7 @@ def test_primary_logo_is_light_when_default_mode_is_light(sphinx_build_factory)
212
212
index_html = sphinx_build .html_tree ("index.html" )
213
213
navbar_brand = index_html .select (".navbar-brand" )[0 ]
214
214
assert navbar_brand .find ("img" , class_ = "only-light" ) is not None
215
- assert navbar_brand .find ("script " , string = re . compile ( "only-dark" ) ) is not None
215
+ assert navbar_brand .find ("img " , class_ = "only-dark" ) is not None
216
216
217
217
218
218
def test_primary_logo_is_dark_when_default_mode_is_dark (sphinx_build_factory ) -> None :
@@ -225,7 +225,7 @@ def test_primary_logo_is_dark_when_default_mode_is_dark(sphinx_build_factory) ->
225
225
index_html = sphinx_build .html_tree ("index.html" )
226
226
navbar_brand = index_html .select (".navbar-brand" )[0 ]
227
227
assert navbar_brand .find ("img" , class_ = "only-dark" ) is not None
228
- assert navbar_brand .find ("script " , string = re . compile ( "only-light" ) ) is not None
228
+ assert navbar_brand .find ("img " , class_ = "only-light" ) is not None
229
229
230
230
231
231
def test_logo_missing_image (sphinx_build_factory ) -> None :
@@ -805,8 +805,9 @@ def test_version_switcher_error_states(
805
805
if url == "switcher.json" : # this should work
806
806
index = sphinx_build .html_tree ("index.html" )
807
807
switcher = index .select (".navbar-header-items" )[0 ].find (
808
- "script " , string = re . compile ( ". version-switcher__container")
808
+ "div " , class_ = " version-switcher__container"
809
809
)
810
+ assert switcher is not None
810
811
file_regression .check (
811
812
switcher .prettify (), basename = "navbar_switcher" , extension = ".html"
812
813
)
@@ -826,11 +827,7 @@ def test_version_switcher_error_states(
826
827
def test_theme_switcher (sphinx_build_factory , file_regression ) -> None :
827
828
"""Regression test for the theme switcher button."""
828
829
sphinx_build = sphinx_build_factory ("base" ).build ()
829
- switcher = (
830
- sphinx_build .html_tree ("index.html" )
831
- .find (string = re .compile ("theme-switch-button" ))
832
- .find_parent ("script" )
833
- )
830
+ switcher = sphinx_build .html_tree ("index.html" ).find (class_ = "theme-switch-button" )
834
831
file_regression .check (
835
832
switcher .prettify (), basename = "navbar_theme" , extension = ".html"
836
833
)
0 commit comments