Skip to content

test: remove bare except from point-feature and core-op tests - #114

Merged
petercorke merged 1 commit into
mainfrom
test/point-feature-bare-except
Oct 3, 2026
Merged

petercorke merged 1 commit into
mainfrom
test/point-feature-bare-except

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Summary

Closes #51.

A bare except: pass also swallows the AssertionError raised by assertGreater, so these tests could never fail. On inspection several never tested anything because they called APIs that don't exist:

Test Problem Fix
test_surf Image.SURF() never existed (and SURF is non-free in pip OpenCV) explicit @unittest.skip pointing at #113
test_corners no Image.corners() renamed test_harris, uses Image.Harris()
test_feature_properties no .uv checks u, v, p, strength
test_concat no Image.concat() split into test_hstack / test_vstack (Hstack/Vstack, note sep=1 default)
test_get_pixel no getpixel() uses pixel(u, v), checks (u,v) = (col,row) order
test_interp2d passed 1-D coordinates; needs (Ho, Wo) arrays 2-D meshgrid, checks values round-trip
test_sift, test_orb, test_features_list_operations, write/read, colorspace, cast worked, just wrapped wrapper removed, real assertions

Also uses .array instead of the deprecated .A. Test-only change; no library code touched.

Verification

  • Clean isolated venvs for OpenCV 4.14.0 and 5.0.0 (Python 3.12): tests/test_image_point_features.py → 20 passed, 1 skipped (SURF) on both.
  • Mutation check: deliberately broke SIFT, ORB, Harris, pixel and Hstack (raising, and returning empty/wrong results) — every one now fails its test. The old tests missed all of them.
  • Only this file was run; the full suite was not.

Follow-ups (not in this PR)

Checklist

  • PR title follows Conventional Commits
  • Tests pass locally (this file only)
  • Added/updated tests for this change
  • CI green

🤖 Generated with Claude Code

A bare 'except: pass' also swallows the AssertionError from assertGreater,
so these tests could never fail. Several also called APIs that do not
exist, so they had never tested anything:

- img.SURF(): never implemented (see #113); now an explicit skip with reason
- img.corners(): the real method is Harris()
- sift.uv: the real attributes are u, v, p
- img.concat(): the real methods are Image.Hstack/Vstack (note sep=1 default)
- img.getpixel(): the real method is pixel(u, v)
- img.interp2d(1-D, 1-D): needs (Ho, Wo) coordinate arrays

Rewritten against the real API with direct assertions, using .array rather
than the deprecated .A. Verified on OpenCV 4.14 and 5.0 (20 passed, 1
skipped), and by deliberately breaking SIFT/ORB/Harris/pixel/Hstack to
confirm each test now fails.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics -17 complexity · 0 duplication

Metric Results
Complexity -17
Duplication 0

View in Codacy

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.

@petercorke
petercorke merged commit 7406d40 into main Oct 3, 2026
35 checks passed
@petercorke
petercorke deleted the test/point-feature-bare-except branch October 3, 2026 19:32
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.

Several point-feature tests use bare except: pass, so a broken detector passes silently

1 participant