test: add initial pytest scaffold for the caption verifier#22
Open
Arvuno wants to merge 1 commit into
Open
Conversation
Adds `[project.optional-dependencies] test = ["pytest>=8"]` and a `[tool.pytest.ini_options]` block to `pyproject.toml`, plus a `tests/` directory with 14 unit tests for `CaptionVerifier`. The caption verifier is the lowest-cost pure helper in the codebase — no model weight, no network, no torch — so it is the natural first target for a test surface. The tests cover well-formed captions, missing required keys, unknown keys, the photo/art_style exclusivity, color palette format and overflow, bbox inversion, unknown element type, invalid JSON, and the ensure_ascii=True heuristic. No production code change.
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a pytest-based test suite for CaptionVerifier and wires up basic pytest configuration and test extras in pyproject.toml.
Changes:
- Added unit tests covering
verify,verify_raw, andcheck_ensure_ascii_falsebehaviors. - Added
testoptional dependency group (pytest) for running tests. - Added pytest configuration (
testpaths,addopts) topyproject.toml.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/test_caption_verifier.py | New tests validating schema/key checks, bbox/color validation, and raw JSON handling. |
| pyproject.toml | Adds pytest as an optional test dependency and configures pytest defaults. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+12
to
+14
| def _valid_caption() -> dict: | ||
| return { | ||
| "high_level_description": "A red apple on a wooden table.", |
Comment on lines
+86
to
+90
| def test_verify_flags_inverted_bbox() -> None: | ||
| caption = _valid_caption() | ||
| caption["compositional_deconstruction"]["elements"][0]["bbox"] = [700, 350, 400, 650] | ||
| warnings = CaptionVerifier().verify(caption) | ||
| assert any("ymin" in w and "ymax" in w for w in warnings) |
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
tests/directory and a pytest scaffold topyproject.toml([project.optional-dependencies] test = ["pytest>=8"]+[tool.pytest.ini_options]).CaptionVerifier, the lowest-cost pure helper in the codebase (no model weight, no torch).photo/art_styleexclusivity, color palette format and overflow, bbox inversion, unknown element type, invalid JSON, and theensure_ascii=Trueheuristic.Why
The repo ships 12 source modules and zero test coverage. The caption verifier is a natural first target — it is pure Python, has no model weight cost, and is the surface most likely to drift (JSON schema evolves).
Testing
pip install -e .[test] && pytest.pytesttest extra.