test(label-file): cover the shape JSON codec directly - #2404
Merged
Conversation
Owner
Author
Verdict: Test-only PR adding direct unit coverage of the shape JSON codec (
Minor, non-blocking: the codec's error branches (missing/mistyped fields) are exercised only indirectly via the pre-existing |
wkentaro
force-pushed
the
test/label-file-shape-codec
branch
from
August 4, 2026 04:56
9555772 to
632f877
Compare
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.
The shape JSON codec (
_load_shape_json_obj/_dump_shape_to_json_objinlabelme/_label_file.py) was only exercised indirectly, through file-I/O-heavyread_label_file/write_label_fileround-trips. The malformed-field errorbranches are already covered directly by
test_read_label_file_raises_on_malformed_shape_field, but the happy-path parsecontract was not: nothing asserted the optional-field defaults (
description->"",group_id->None,flags->{}), unknown-key bucketing intoother_data, the falsy-but-validgroup_id: 0case, or the mask base64encode/decode, so a regression in any default would pass the whole suite.
These direct unit tests pin that contract with no filesystem access, building
mask input via the production
img_arr_to_b64encoder rather than hand-rolledbase64.
Test plan
uv run pytest tests/unit/_label_file_test.py -q(56 passed)uv run ruff check/ruff format --check/ty checkon the file