Skip to content

test: add initial pytest scaffold for the caption verifier#22

Open
Arvuno wants to merge 1 commit into
ideogram-oss:mainfrom
Arvuno:test/initial-pytest-scaffold
Open

test: add initial pytest scaffold for the caption verifier#22
Arvuno wants to merge 1 commit into
ideogram-oss:mainfrom
Arvuno:test/initial-pytest-scaffold

Conversation

@Arvuno

@Arvuno Arvuno commented Jun 7, 2026

Copy link
Copy Markdown

Summary

  • Adds a tests/ directory and a pytest scaffold to pyproject.toml ([project.optional-dependencies] test = ["pytest>=8"] + [tool.pytest.ini_options]).
  • 14 unit tests for CaptionVerifier, the lowest-cost pure helper in the codebase (no model weight, no torch).
  • Coverage: well-formed captions, missing required keys, unknown top-level keys, the photo/art_style exclusivity, color palette format and overflow, bbox inversion, unknown element type, invalid JSON, and the ensure_ascii=True heuristic.

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

  • Tests are runnable locally with pip install -e .[test] && pytest.
  • The PR does not run pytest in CI here; the maintainer can wire it in. (The pre-commit config in this repo does not currently include pytest.)
  • No production code change; no new runtime dependencies; only a pytest test extra.

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.
Copilot AI review requested due to automatic review settings June 7, 2026 20:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and check_ensure_ascii_false behaviors.
  • Added test optional dependency group (pytest) for running tests.
  • Added pytest configuration (testpaths, addopts) to pyproject.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)
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.

2 participants