Skip to content

test: dispose canvases after every GUI test; classmethod qapp fixture - #190

Merged
danyill merged 1 commit into
mainfrom
test/canvas-cleanup-and-qapp-fixture
Nov 8, 2026
Merged

danyill merged 1 commit into
mainfrom
test/canvas-cleanup-and-qapp-fixture

Conversation

@danyill

@danyill danyill commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Closes 189

  • tests/conftest.py: _dispose_new_views runs in the per-test hygiene. It closes and deleteLater()s every parentless DiagramView built during the test and drains DeferredDelete, so Qt frees it in its own order instead of gc.collect() doing it (the segfault seen on Filter row for large results tables and the Data Tables #172 and Data Tables: Whole model, multi-row edit, button spacing; document the filters #176). Views that existed before the test (module/class fixtures), views inside a window (_reap handles those) and views a fixture already deleted are skipped.
  • tests/unit/test_view_disposal_hygiene.py: four tests for that step (fails without it).
  • tests/unit/test_start_to_end_and_units.py: the module-scoped qapp fixture is a @classmethod (clears PytestRemovedIn10Warning).

The per-file cleanups in test_gui_tool_cursor.py and test_routing_nodes.py are left as they are; they are harmless alongside this.
Ran locally: all 49 files that build a DiagramView, with the deprecation warning as an error for the touched ones. ruff and the mypy gate are clean.

The per-test hygiene now closes and deletes, with Qt, every parentless
DiagramView the test built (views from wider-scoped fixtures, views inside
a window and views a fixture already deleted are left alone), so no shown
canvas is left for gc.collect() to tear down in an unsafe order.

The module-scoped qapp fixture in test_start_to_end_and_units.py becomes a
classmethod, clearing PytestRemovedIn10Warning.
@danyill
danyill merged commit 196c919 into main Nov 8, 2026
48 checks passed
@danyill
danyill deleted the test/canvas-cleanup-and-qapp-fixture branch November 8, 2026 01:40
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