Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
drammock committed Oct 29, 2023
1 parent a23aee6 commit 9de51f4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
1 change: 1 addition & 0 deletions tests/sites/deprecated/conf.py
Expand Up @@ -22,6 +22,7 @@
# Base options, we can add other key/vals later
html_theme_options = {
"search_bar_position": "navbar",
"surface_warnings": True,
"logo_text": "DOCS",
"footer_items": ["page-toc.html"],
"favicons": [
Expand Down
4 changes: 2 additions & 2 deletions tests/test_a11y.py
Expand Up @@ -135,6 +135,6 @@ def test_version_switcher_highlighting(page: Page, url_base: str) -> None:
assert entries.count() == 2
# make sure they're highlighted
for entry in entries.all():
light_mode = "rgb(39, 107, 233)"
# dark_mode = "rgb(121, 163, 142)"
light_mode = "rgb(10, 125, 145)" # pst-color-primary
# dark_mode = "rgb(63, 177, 197)"
expect(entry).to_have_css("color", light_mode)
27 changes: 18 additions & 9 deletions tests/test_build.py
Expand Up @@ -7,6 +7,11 @@
import sphinx.errors
from pydata_sphinx_theme.utils import escape_ansi

COMMON_CONF_OVERRIDES = dict(
navigation_with_keys=False,
surface_warnings=True,
)


def test_build_html(sphinx_build_factory, file_regression) -> None:
"""Test building the base html template and config."""
Expand Down Expand Up @@ -238,7 +243,7 @@ def test_logo_missing_image(sphinx_build_factory) -> None:
# Test with a specified title and a dark logo
confoverrides = {
"html_theme_options": {
"navigation_with_keys": False,
**COMMON_CONF_OVERRIDES,
"logo": {
# The logo is actually in _static
"image_dark": "emptydarklogo.png",
Expand Down Expand Up @@ -753,7 +758,7 @@ def test_version_switcher_error_states(
"""
confoverrides = {
"html_theme_options": {
"navigation_with_keys": False,
**COMMON_CONF_OVERRIDES,
"navbar_end": ["version-switcher"],
"switcher": {
"json_url": url,
Expand All @@ -778,7 +783,10 @@ def test_version_switcher_error_states(
assert not_read in escape_ansi(sphinx_build.warnings).strip()

elif url == "missing_url.json": # this file is missing the url key for one version
missing_url = 'WARNING: The version switcher "missing_url.json" file is malformed at least one of the items is missing the "url" or "version" key'
missing_url = (
'WARNING: The version switcher "missing_url.json" file is malformed; '
'at least one of the items is missing the "url" or "version" key'
)
assert escape_ansi(sphinx_build.warnings).strip() == missing_url


Expand Down Expand Up @@ -814,14 +822,15 @@ def test_math_header_item(sphinx_build_factory, file_regression) -> None:


@pytest.mark.parametrize(
"style_names,keyword_colors",
[
(("fake_foo", "fake_bar"), ("#204a87", "#66d9ef")),
(
("style_names", "keyword_colors"),
(
pytest.param(("fake_foo", "fake_bar"), ("#204a87", "#66d9ef"), id="fake"),
pytest.param(
("a11y-high-contrast-light", "a11y-high-contrast-dark"),
("#7928a1", "#dcc6e0"),
id="real",
),
],
),
)
def test_pygments_fallbacks(sphinx_build_factory, style_names, keyword_colors) -> None:
"""Test that setting color themes works.
Expand All @@ -831,7 +840,7 @@ def test_pygments_fallbacks(sphinx_build_factory, style_names, keyword_colors) -
"""
confoverrides = {
"html_theme_options": {
"navigation_with_keys": False,
**COMMON_CONF_OVERRIDES,
"pygment_light_style": style_names[0],
"pygment_dark_style": style_names[1],
},
Expand Down

0 comments on commit 9de51f4

Please sign in to comment.