Skip to content

FIX SVM click-simulation tests failing on headless CI - #57

Merged
mkiani12 merged 1 commit into
mainfrom
hotfix/svm-headless-test-guard
Aug 21, 2026
Merged

FIX SVM click-simulation tests failing on headless CI#57
mkiani12 merged 1 commit into
mainfrom
hotfix/svm-headless-test-guard

Conversation

@mkiani12

Copy link
Copy Markdown
Collaborator

Fixes the red FEZrs Tests run on main (run 32463258511).

What broke

FAILED tests/tools/svm/svm_calculator_test.py::test_nonsquare_training_samples_use_opencv_xy_as_numpy_yx
FAILED tests/tools/svm/svm_calculator_test.py::test_nonsquare_output_shape_and_pixel_order
RuntimeError: SVMCalculator needs training_samples when no display is available.

My fault, from the non-interactive SVM PR. That PR added a display check in front of the OpenCV window so a headless run raises a catchable error instead of Qt aborting the process. These two pre-existing tests drive the interactive path with every cv2 entry point mocked — but not display_is_available(). The guard runs before any of the mocked calls, so:

  • workstation: DISPLAY is set → guard passes → mocked window runs → tests pass
  • CI runner: no DISPLAY → guard raises → process() never reaches the simulated clicks → tests fail

I updated test_process_creates_rgb_stack for exactly this when I changed its ESC behaviour, but missed these two because they live in a separate helper further down the file and passed locally.

Fix

Force the display check on inside _run_process_with_clicks, matching what the ESC test already does. The helper mocks the entire GUI, so whether a real display exists is irrelevant to what these tests assert.

Test-only change. No library behaviour is affected, and the guard itself is unchanged.

Verification

Ran the full suite under env -u DISPLAY -u WAYLAND_DISPLAY, which reproduces the CI environment:

headless:      421 passed
with display:  421 passed

Previously headless gave 2 failures. Worth noting for future changes to this module: a plain local pytest run does not exercise the headless path, so anything touching the display guard should be checked with DISPLAY unset.

The display guard added with the non-interactive training path made two
existing tests environment dependent:

    test_nonsquare_training_samples_use_opencv_xy_as_numpy_yx
    test_nonsquare_output_shape_and_pixel_order

Both drive the interactive path with every cv2 entry point mocked, but they do
not mock display_is_available(). On a workstation DISPLAY is set, so the guard
passes and the mocked window runs; on a headless runner the guard fires first
and process() raises before reaching the simulated clicks.

Force the display check on in _run_process_with_clicks, matching what the ESC
interrupt test already does. The helper mocks the whole GUI, so the real
availability of a display is irrelevant to what these tests assert.

Test-only change; no library behavior is affected. Verified with the full
suite run under `env -u DISPLAY -u WAYLAND_DISPLAY`, which reproduces the CI
environment.
@mkiani12
mkiani12 merged commit 90b9533 into main Aug 21, 2026
1 check passed
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.

1 participant