Repository navigation
test: move the block tests into tests/ and run them in CI - #217
Merged
Merged
Conversation
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>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 31 |
| Duplication | 0 |
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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),testpathsistests, and bdsim was not installed in CI. This PR makes them run. Six commits:Moves the tests to
tests/test_blocks.py, deletes the old file, and usespytest.importorskip("bdsim")instead of a star-import probe. bdsim stays optional.Adds
bdsim>=1.5.0to thedevextra, which CI installs, plus a newblocksextra andall.Replaces the skipped
test_estpose: its reason (a spatialmathEulerVecbug) no longer applies in spatialmath 1.1.19.EstPose_pis now checked againstCentralCamera.estposeand against the pose that generated the points.Adds tests for
ImagePlanewith 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,retainandinit.Removes the coverage exclusions for
blocks/*frompyproject.tomland from the coverage command inci.yml. The second pattern,src/machinevision/blocks, named a path that does not exist.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.pyhas 29 tests, and coverage ofblocks/camera.pyis 94%.mypyandruffreport 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
ImagePlanetests I noticed three things, which are not changed here and not pinned by the tests: starting anImagePlaneopens a second, unused figure (bdsim's base class already makes one); it still creates a figure when the run hasgraphics=False; andVisjac_pstoresdepthestbut 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