Skip to content

GUI tests that poll the file model for a fixed 2 s fail under CPU load #24

Closed

Description

@NaNIsaac

Symptom

With every CPU core busy, tests/test_gui.py fails in 7 of 10 runs on the branch of #22 (6badf80), always at test_arrow_keys_move_the_preview (tests/test_gui.py:438, assert 0 >= 2: the explorer lists no .tif files). It passes when the machine is idle.

Cause

The test waits for QFileSystemModel to fill the folder with a fixed budget:

for _ in range(20):  # QFileSystemModel populates asynchronously
    pump(100)
    if model.rowCount(tree.rootIndex()) >= len(three_tifs):
        break

That is 2 s. The model fills the folder on a worker thread, and with the cores saturated the thread does not get to run in that time. test_arrow_keys_do_nothing_without_a_preview_tab (line 465) has the same loop, and several tests use a bare pump(200) or pump(400) before reading the tree.

#22 added a wait_until fixture for exactly this and applied it to the filter tests only.

Reproduce

On the branch of #22, with 12 busy-loop processes running (one per logical CPU):

QT_QPA_PLATFORM=offscreen uv run pytest -q -x tests/test_gui.py

3 passed and 7 failed in 10 runs. The filter tests (earlier in the file) passed in all 10, and in 20 more runs of -k "filter or escape or clearing".

Expected

The tests wait on the condition (wait_until(lambda: model.rowCount(root) >= n, describe=...)) instead of a fixed time, so a loaded machine slows them down without failing them. Because -x stopped each failing run at this test, later tests may have the same problem; the count is a lower bound.

Activity

  1. NaNIsaac commented on Oct 25, 2026

    @NaNIsaac
    OwnerAuthor

    Closing as fixed. PR #29 (merged 2026-10-23, 33ef6e7) replaced the fixed 2 s poll with a wait_until of up to 30 s, and PR #26 (merged 2026-10-24, 2b6ebcf) moved the arrow-key tests onto the same wait_for_listing helper. tests/test_gui.py on main has no fixed sleep left.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions