Repository navigation
test: raise coverage of ImageIO from 55% to 88% and ImageTensor from 76% to 90% - #222
Merged
Merged
Conversation
…76% to 90% The tests use synthetic images, temporary files with known EXIF values, and simulated mouse events. The only stand-in is for the native file-chooser dialogue in Image.Read(). Three bugs are recorded as strict xfail tests: Image.Read() with a wildcard that matches files raises a bare AssertionError, the stdisp click handler passes scalars to Line2D.set_xdata which Matplotlib 3.11 refuses, and stdisp keeps its cursor only in a local variable so it is lost when show() does not block. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 72 |
| 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
First of three changes lifting coverage of the last
Image*.pymodules.ImageIO.pygoes from 55% to 88% andImageTensor.pyfrom 76% to 90%.The tests are in two new files,
tests/test_image_io_extra.pyandtests/test_image_tensor_extra.py. They use synthetic images, files in a temporary folder with known EXIF values, and simulated mouse events, so the expected answers are exact:Image.Read: thealphaandrgboptions, the color order, the argument check, and a wildcard.metadata: JPEGs written with known EXIF tags, so int, text, text that holds a number, and float values each come back as the right type.showpixelsandshowwindow: the label at each pixel for int, float and bool images, NaN pixels, the grid, colormaps, and the window moving over the image and returning its pixels.dispwith an image domain,anaglyphwith each disparity sign, andstdisp.tensorandImage.Tensor: the ImageNet and custom normalisation, dictionary input, the type and batch errors, and the error when PyTorch is missing.Three bugs found while writing these are recorded as strict
xfailtests, not fixed here, so whoever fixes one has to remove its marker:Image.Readwith a wildcard that matches files raises a bareAssertionError, not its ownValueError("wildcard read not supported").ireadreturns(images, paths)for a wildcard, whichImage.Readtakes for one image.stdisp: clicking in the left image raisesRuntimeError: y must be a sequence, because the click handler passes scalars toLine2D.set_xdataandset_ydata, which Matplotlib 3.11 refuses.stdispkeeps its cursor only in a local variable, and Matplotlib holds callbacks weakly, so whereplt.show(block=True)returns at once (a notebook, or a non-interactive backend) the clicks do nothing.Testing
pytest tests: 1800 passed, 33 skipped, 9 xfailed.black,ruff checkandmypyreport no issues. The only stand-in is for the native file-chooser dialogue inImage.Read()and forplt.show(block=True)in thestdisptest, which plays the part of the user clicking. The tensor tests are skipped where PyTorch is not installed. 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