Ignore queued management completion after its Qt receiver is destroyed. Isolate unrelated WMI and file-proof latency in simulated lifecycle tests while retaining real occupancy and writer-barrier coverage. Validation: 2428 tests passed, compile and whitespace checks passed, scoped review clean. Field ICDB inconsistency and Windows 10/production SMB remain unaccepted.
33 lines
1.3 KiB
Python
33 lines
1.3 KiB
Python
"""Queued worker completion must not touch a destroyed management dialog."""
|
|
import pytest
|
|
from PySide6.QtWidgets import QMessageBox
|
|
from shiboken6 import delete, isValid
|
|
|
|
|
|
@pytest.mark.parametrize('failed', [False, True])
|
|
def test_queued_management_completion_ignores_deleted_receiver(qtbot, tmp_path, monkeypatch, failed):
|
|
from cbb_refresh_verify.management import ManagementRequest
|
|
from cbb_refresh_verify.ui import timed_prompt
|
|
from cbb_refresh_verify.ui.management_dialog import ManagementDialog
|
|
|
|
def run(*args, **kwargs):
|
|
if failed:
|
|
raise ValueError('simulated native-boundary failure')
|
|
return []
|
|
monkeypatch.setattr(timed_prompt, 'question', lambda *args, **kwargs: QMessageBox.Yes)
|
|
dialog = ManagementDialog([ManagementRequest('remove', tmp_path/'library.lmc', 'Block',
|
|
evidence_dir=tmp_path/'evidence')], runner=run)
|
|
completed = []
|
|
dialog.completed.connect(completed.append)
|
|
try:
|
|
dialog.execute_button.click()
|
|
worker = dialog.worker # Retain the real sender while its queued signals are delivered.
|
|
assert dialog.pool.waitForDone(3000)
|
|
delete(dialog)
|
|
assert not isValid(dialog)
|
|
qtbot.wait(30)
|
|
assert not completed
|
|
finally:
|
|
if isValid(dialog):
|
|
delete(dialog)
|