Skip to content

test: skip kaleido image-export tests when no browser is available - #833

Merged
tschm merged 1 commit into
mainfrom
fix/kaleido-skip-no-browser
Jun 16, 2026
Merged

test: skip kaleido image-export tests when no browser is available#833
tschm merged 1 commit into
mainfrom
fix/kaleido-skip-no-browser

Conversation

@tschm

@tschm tschm commented Jun 16, 2026

Copy link
Copy Markdown
Member

Summary

make test failed locally with a 300-second hang in
test_kaleido.py::test_portfolio_snapshot_write_image. Root cause: kaleido v1
renders images by driving a headless Chrome subprocess. In a dev
environment where the plot extra (kaleido) is installed but no Chrome/Chromium
is present — and none has been downloaded via plotly_get_chrome
to_image()/write_image() block forever and the pytest-timeout watchdog
kills them at 300s. The same tests pass on CI, where GitHub runners ship Chrome.

The existing guards covered kaleido-not-installed (importorskip) and
Windows (skipif), but not kaleido-installed-but-no-browser.

Change

tests/test_jquantstats/test__plots/test_kaleido.py: add a _chrome_available()
helper and a skipif marker. It resolves a browser exactly the way kaleido
does — choreographer.browsers.chromium.get_browser_path(...), which honours
$BROWSER_PATH and the choreographer download cache — and skips the 5
image-export tests cleanly when none is found. If choreographer's API ever
moves, the helper falls back to not skipping, so CI never silently loses
coverage.

Verification

  • Kaleido tests now skip in 0.05s with a clear reason instead of the 300s hang.
  • make fmt: ✅ green.
  • make test: ✅ exit 0 — 1210 passed, 5 skipped, no failures.
  • Coverage gate: ✅ still 100.00% (2968/2968) — the skipped tests are not the sole cover for any src/ line.

Scope: locally-owned tests/ only; no src/ or Rhiza-managed files touched.

🤖 Generated with Claude Code

kaleido v1 renders via a headless Chrome subprocess. In a dev environment
with the 'plot' extra installed but no Chrome/Chromium (and no browser
downloaded via plotly_get_chrome), to_image()/write_image() block until the
300s watchdog kills them — make test fails on a 5-minute hang.

Add a _chrome_available() guard that resolves a browser the same way kaleido
does (choreographer's chromium locator, honouring $BROWSER_PATH and the
choreo download cache) and skips the 5 image-export tests cleanly when none
is found. If choreographer's API ever moves, it falls back to NOT skipping so
CI — where Chrome ships on the runners — never silently loses coverage.

Verified: tests skip in 0.05s locally; full suite 1210 passed, 5 skipped;
coverage still 100%.
Copilot AI review requested due to automatic review settings June 16, 2026 16:42
@tschm
tschm merged commit c07a5f3 into main Jun 16, 2026
61 checks passed
@tschm
tschm deleted the fix/kaleido-skip-no-browser branch June 16, 2026 16:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes the Kaleido image-export tests resilient in developer environments where kaleido is installed but Chrome/Chromium is not present (which otherwise can cause to_image()/write_image() to hang until the pytest timeout triggers).

Changes:

  • Add a _chrome_available() helper to detect whether Kaleido can locate a Chromium-based browser via choreographer.
  • Skip Kaleido image-export tests when no browser is available (in addition to the existing Windows skip), avoiding long hangs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +29 to +30
if os.environ.get("BROWSER_PATH"):
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants