Skip to content

Strengthen coverage tests to assert UI behavior #46

Description

@JoshCLWren

Problem

The recent coverage additions in tests/test_coverage_additions.py increase line coverage, but several tests do not verify the behavior they describe. Examples include:

  • Tests that manually recalculate the expected anchor/y values instead of asserting the canvas state produced by _display_image_fast.
  • test_open_dialog_applies_color, which does not actually drive the color-entry callback or assert a color change.
  • Tests that call methods only to ensure they do not raise, without checking the resulting state or user-visible behavior.
  • Production # pragma: no cover markers added around dialog callbacks and cleanup paths without a focused behavioral test.

These tests can pass while the underlying UI behavior is broken and make the 96% coverage target less meaningful.

Fix

  • Rewrite coverage-only tests into behavior-focused regression tests.
  • Assert canvas item coordinates/anchors, scroll offsets, dialog state, pending quit state, applied colors, cleanup state, and worker scheduling outcomes directly.
  • Remove unnecessary # pragma: no cover markers where realistic tests can exercise the code.
  • Keep tests deterministic with the existing tk_root fixture.

Verification

  • Temporarily mutate the relevant production branch and confirm each regression test fails for the intended reason.
  • Run the full coverage command and inspect the missing-line report.
  • Do not weaken benchmark tests or mock the I/O paths covered by performance tests.

Done criteria

  • New tests assert observable behavior rather than duplicating implementation calculations.
  • The tests fail against representative mutations.
  • Coverage remains at or above the project threshold without gratuitous exclusions.
  • Full lint, type, and test checks pass.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions