Skip to content

test: run every example script headless as a smoke test - #207

Merged
petercorke merged 5 commits into
mainfrom
test/examples-run-smoke
Nov 22, 2026
Merged

petercorke merged 5 commits into
mainfrom
test/examples-run-smoke

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Summary

Adds tests/test_examples_run.py, which runs every script in examples/ in its own process as a smoke test. It sets MPLBACKEND=Agg so plots do not block, and turns DeprecationWarning into an error, so an example that uses a removed or deprecated Toolbox API fails in CI rather than in front of a reader. This is how the broken morphdemo.py (PR 195, merged) and monalisa.py (PR 197, merged) were found.

  • A new example is tested by default; nothing needs registering.
  • Six examples are skipped, each with a stated reason: bunny.py, showzip.py and randomdots.py need a window; ros_stream.py needs a rosbridge server; torch-yolo.py and torch_seg.py need torch models downloaded.
  • monalisa.py fetches from the internet, so a network failure skips it rather than failing.

Testing

Locally, on OpenCV 5.0 and Python 3.12: 8 passed, 6 skipped, about 35 seconds. Not run: OpenCV 4, Windows. The CI matrix will do that on this PR, and I have not checked the extra CI time against the matrix.

This change was written with AI assistance (Claude Code) and the diff has been read by the maintainer.

🤖 Generated with Claude Code

@codacy-production

codacy-production Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 1 critical

Alerts:
⚠ 1 issue (≤ 0 issues of at least minor severity)

Results:
1 new issue

Category Results
Security 1 critical

View in Codacy

🟢 Metrics 8 complexity · 0 duplication

Metric Results
Complexity 8
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

petercorke and others added 3 commits November 22, 2026 10:59
Runs each examples/*.py in a subprocess with MPLBACKEND=Agg and
DeprecationWarning turned into an error. Scripts that need a display,
a camera, ROS, a GPU model or a large download are skipped with a stated
reason, and monalisa.py is skipped when the network is unavailable.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@petercorke
petercorke force-pushed the test/examples-run-smoke branch from 8cf2129 to ff0b10e Compare November 22, 2026 00:59
petercorke and others added 2 commits November 22, 2026 11:02
morphdemo --frames N stops after N updates of the output image, so the
smoke test runs five frames instead of every pixel and no longer needs a
longer timeout on slow CI runners.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@petercorke
petercorke merged commit 382d09c into main Nov 22, 2026
31 of 32 checks passed
@petercorke
petercorke deleted the test/examples-run-smoke branch November 22, 2026 01:39
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.

1 participant