fix: preserve async writer ownership and bounded handoff
This commit is contained in:
1 parent
ddff6bd857
commit
8374cabe5c
12 files changed
+692
-47
No files matched your search
@@ -7,6 +7,20 @@ import pytest
|
||||
ERROR = b'REUSE BLOCK: INFORMATION: Block\tError! Cannot copy iCDB base of Reusable Block project.\r\n'
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def owned_add_process(monkeypatch):
|
||||
import subprocess, sys
|
||||
from cbb_refresh_verify import desktop_worker
|
||||
monkeypatch.setattr(desktop_worker, '_automation_clients', [])
|
||||
process = subprocess.Popen([sys.executable, '-c', 'input()'], stdin=subprocess.PIPE, text=True)
|
||||
try:
|
||||
yield process
|
||||
finally:
|
||||
process.communicate('\n', timeout=3)
|
||||
for operation in desktop_worker._automation_clients:
|
||||
assert operation.poll() is not None
|
||||
|
||||
|
||||
@pytest.mark.parametrize('change', ['', 'target', 'pcb_present', 'question', 'extra_button', 'wrong_button', 'escape'])
|
||||
def test_editor_missing_pcb_notice_is_only_for_unrelated_incomplete_entries(tmp_path, change):
|
||||
from cbb_refresh_verify.native_add_failures import missing_other_pcb_notice
|
||||
@@ -54,7 +68,7 @@ def test_add_timeout_publishes_cancellation_without_killing_native_owner(tmp_pat
|
||||
|
||||
@pytest.mark.parametrize('cancel', [True, False])
|
||||
@pytest.mark.parametrize('journal_error', [False, True])
|
||||
def test_cancellation_and_phase_at_native_add_submit(tmp_path, monkeypatch, cancel, journal_error):
|
||||
def test_cancellation_and_phase_at_native_add_submit(tmp_path, monkeypatch, cancel, journal_error, owned_add_process):
|
||||
import os,sys
|
||||
from types import SimpleNamespace
|
||||
import win32gui,win32process
|
||||
@@ -70,7 +84,7 @@ def test_cancellation_and_phase_at_native_add_submit(tmp_path, monkeypatch, canc
|
||||
tab=SimpleNamespace(window_text=lambda:'Logical - Physical',is_selected=lambda:True)
|
||||
monkeypatch.setitem(sys.modules,'pywinauto',SimpleNamespace(Desktop=lambda **k:SimpleNamespace(
|
||||
window=lambda **k:SimpleNamespace(descendants=lambda **k:[tab]))))
|
||||
monkeypatch.setattr(win32process,'GetWindowThreadProcessId',lambda h:(1,99))
|
||||
monkeypatch.setattr(win32process,'GetWindowThreadProcessId',lambda h:(1,owned_add_process.pid))
|
||||
monkeypatch.setattr(win32gui,'IsWindowVisible',lambda h:True)
|
||||
monkeypatch.setattr(win32gui,'IsWindowEnabled',lambda h:True)
|
||||
monkeypatch.setattr(win32gui,'GetWindowText',lambda h:{100:'Reusable Blocks',200:'New Reusable Block'}[int(h)])
|
||||
@@ -102,7 +116,7 @@ def test_cancellation_and_phase_at_native_add_submit(tmp_path, monkeypatch, canc
|
||||
expected = OSError if journal_error and not cancel else RuntimeError
|
||||
message = 'NATIVE_ADD_CANCELLED' if cancel else 'phase journal unavailable' if journal_error else 'unsafe OK posted'
|
||||
with pytest.raises(expected, match=message):
|
||||
native._probe_add_dialog_impl(SimpleNamespace(OnReusableBlocksEditor=lambda:None),job,desktop,{99},root)
|
||||
native._probe_add_dialog_impl(SimpleNamespace(OnReusableBlocksEditor=lambda:None),job,desktop,{owned_add_process.pid},root)
|
||||
assert state['posted']==([110] if cancel or journal_error else [110,210])
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user