test: keep release preview assertions scoped to the fixture

This commit is contained in:
阿白叔 committed 2026-11-25 18:44:52 +08:00
1 parent 7d9a107921
commit 81a5d1ae4b
1 file changed
+7 -4
+7 -4
View File
@@ -157,13 +157,16 @@ def test_residual_dialog_refresh_shows_runtime_blocker_without_releasing(qtbot,
library = tmp_path/'library/lib.lmc' library = tmp_path/'library/lib.lmc'
library.parent.mkdir(); library.touch() library.parent.mkdir(); library.touch()
monkeypatch.setattr(locks, 'inspect_residual_sessions', lambda *_: {'library': str(library), 'sessions': []}) monkeypatch.setattr(locks, 'inspect_residual_sessions', lambda *_: {'library': str(library), 'sessions': []})
release = locks.release_retained_library
releases = [] releases = []
def unexpected_release(*args, **kwargs): def check_release(target, *args, **kwargs):
releases.append((args, kwargs)) if Path(target) == library:
raise OSError('Preview started a release') releases.append(target)
raise OSError('Preview started a release')
return release(target, *args, **kwargs)
monkeypatch.setattr(locks, 'release_retained_library', unexpected_release) monkeypatch.setattr(locks, 'release_retained_library', check_release)
dialog = ResidualReleaseDialog(library, tmp_path/'release-checks') dialog = ResidualReleaseDialog(library, tmp_path/'release-checks')
qtbot.addWidget(dialog) qtbot.addWidget(dialog)
qtbot.waitUntil(lambda: not dialog.busy) qtbot.waitUntil(lambda: not dialog.busy)