Skip to content

test: move the block tests into tests/ and run them in CI - #217

Merged
petercorke merged 8 commits into
mainfrom
test/blocks-in-ci
Nov 22, 2026
Merged

petercorke merged 8 commits into
mainfrom
test/blocks-in-ci

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Summary

The bdsim block tests were never run by pytest or CI. They lived in src/machinevisiontoolbox/blocks/test_blocks.py, inside the package (so they shipped in the wheel), testpaths is tests, and bdsim was not installed in CI. This PR makes them run. Six commits:

  1. Moves the tests to tests/test_blocks.py, deletes the old file, and uses pytest.importorskip("bdsim") instead of a star-import probe. bdsim stays optional.

  2. Adds bdsim>=1.5.0 to the dev extra, which CI installs, plus a new blocks extra and all.

  3. Replaces the skipped test_estpose: its reason (a spatialmath EulerVec bug) no longer applies in spatialmath 1.1.19. EstPose_p is now checked against CentralCamera.estpose and against the pose that generated the points.

  4. Adds tests for ImagePlane with nothing drawn (parameters, style, errors) and in a real bdsim run on the Agg backend (constant point, CAMERA, IMAGEPLANE): the point is drawn where the camera projects it, plus title, style, retain and init.

  5. Removes the coverage exclusions for blocks/* from pyproject.toml and from the coverage command in ci.yml. The second pattern, src/machinevision/blocks, named a path that does not exist.

  6. Makes the simulation tests pass sysargs=False, because bdsim otherwise reads pytest's command line as its own options.

Only blocks defined in MVTB are tested, not bdsim's own.

Testing

pytest tests: 1566 passed, 33 skipped. tests/test_blocks.py has 29 tests, and coverage of blocks/camera.py is 94%. mypy and ruff report no issues. The block tests use bdsim 1.5.0 and a real simulation, and nothing is mocked. Not run: CI on Windows or Python 3.14 with bdsim installed (CI will), and a simulation with a live window.

While writing the ImagePlane tests I noticed three things, which are not changed here and not pinned by the tests: starting an ImagePlane opens a second, unused figure (bdsim's base class already makes one); it still creates a figure when the run has graphics=False; and Visjac_p stores depthest but never uses it.

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

🤖 Generated with Claude Code

petercorke and others added 6 commits November 22, 2026 13:43
The block tests lived in src/machinevisiontoolbox/blocks/test_blocks.py,
so they shipped in the wheel and pytest's testpaths never collected them.
Moves the Camera and Visjac_p tests to tests/test_blocks.py, uses
pytest.importorskip("bdsim") instead of a star-import probe, and adds
cases for several points, the default depth and a missing camera.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
CI installs .[dev,tool], so the block tests now run there. bdsim stays
optional for users: the new blocks extra, and all, install it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Replaces the skipped test_estpose, whose reason (a spatialmath EulerVec
bug) no longer applies in spatialmath 1.1.19. Checks the block against
CentralCamera.estpose and against the pose that generated the points,
that method is passed on, and that a missing camera raises.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Checks the style, init and other parameters without drawing, then runs a
small diagram (constant point to CAMERA to IMAGEPLANE) in a real bdsim
simulation on the Agg backend and checks the point is drawn where the
camera projects it, the title, the style, retain and the init function.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The blocks module was excluded from coverage, both in pyproject.toml and
in the coverage command in ci.yml, because its tests were not run. They
are now, so the exclusions go. The second pattern, src/machinevision/blocks,
named a path that does not exist.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
bdsim takes its options from sys.argv unless told not to, so a pytest
option such as -p was read as a bdsim option and wrote a stray file.
The simulation tests now pass sysargs=False.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 31 complexity · 0 duplication

Metric Results
Complexity 31
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
petercorke merged commit 3832e5d into main Nov 22, 2026
32 checks passed
@petercorke
petercorke deleted the test/blocks-in-ci branch November 22, 2026 05:23
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