tests: Properly delete mode_manager instances

To fix a flaky tests/unit/utils/usertypes/test_timer.py::test_early_timeout_check
(where a download-update timer from an earlier test fails), I looked into what
usertypes.Timer instances where left over after a test finished.

It turns out that there were about 190 still existing "partial-match" and
"normal-inhibited" timers when breaking in test_timer.py, even when just running
tests in tests/unit/browser/ and tests/unit/utils/usertypes.

This is because we pass qapp as parent to the ModeManager we create, but that
means it will be forever alive if we don't take care of cleaning it up after a
test.

Perhaps our tests should have some sort of mechanism that checks whether there
are any "leftovers" after a test has finished (perhaps even as part of
pytest-qt?), but for now, let's just fix the issues we can directly see.
This commit is contained in:
Florian Bruhin 2025-05-07 13:22:10 +02:00
parent ed99c82440
commit 9f16a1f879
1 changed files with 1 additions and 0 deletions

View File

@ -533,6 +533,7 @@ def mode_manager(win_registry, config_stub, key_config_stub, qapp):
mm = modeman.init(win_id=0, parent=qapp)
yield mm
objreg.delete('mode-manager', scope='window', window=0)
mm.deleteLater()
def standarddir_tmpdir(folder, monkeypatch, tmpdir):