Skip to content

test: raise coverage of base/version.py, meshgrid.py and data.py to over 90% - #211

Merged
petercorke merged 2 commits into
mainfrom
test/base-coverage-small
Nov 22, 2026
Merged

petercorke merged 2 commits into
mainfrom
test/base-coverage-small

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Summary

First of three changes to bring every file in machinevisiontoolbox/base to at least 80% coverage. This one covers the three smallest:

File Before After
base/version.py 14% 93%
base/meshgrid.py 42% 100%
base/data.py 64% 100%
  • meshgrid.py already had thorough tests, but tests/base/test_meshgrid.py loaded the module by running its source text with exec, so coverage could not see them. It now uses a normal import; no test changed.
  • New tests/base/test_version.py checks that mvtb_version reports the installed versions of the Toolbox, spatialmath, NumPy and OpenCV, and the OpenCV build information.
  • tests/base/test_data.py gains tests that read real files: bunny.mat from mvtbdata, a .mat file with a MATLAB struct (returned as a namedtuple), and a JSON file, plus the missing-file errors and the string=True and absolute-path options of mvtb_path_to_datafile.
  • Removes one unused variable in test_data.py.

The remaining base files, imageio.py and color.py, follow in separate PRs.

Testing

pytest tests/base: 285 passed, 2 skipped. Coverage was measured with coverage run --source=src/machinevisiontoolbox/base on the three files above. mypy reports no issues. All tests read real files; nothing is mocked. Not run: CI on Windows or OpenCV 4 (CI will).

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

🤖 Generated with Claude Code

…ver 90%

meshgrid.py already had thorough tests, but they loaded the module by
exec of its source text, so coverage could not see them. They now use a
normal import. Adds tests for mvtb_version (new test_version.py), the
MATLAB and JSON data loaders, and the path and string options of
mvtb_path_to_datafile.

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 9 complexity · 0 duplication

Metric Results
Complexity 9
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 f7671f2 into main Nov 22, 2026
32 checks passed
@petercorke
petercorke deleted the test/base-coverage-small branch November 22, 2026 02:56
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