fix: hand off UI shutdown without releasing native ownership
This commit is contained in:
1 parent
cd7a5e0ca1
commit
dbc685b9a5
10 files changed
+454
-52
No files matched your search
@@ -115,7 +115,28 @@ def test_reader_never_creates_a_desktop_or_process(monkeypatch, tmp_path, reader
|
||||
import win32service
|
||||
import win32process
|
||||
import cbb_refresh_verify.mentor_adapter as module
|
||||
from pywinauto import Desktop
|
||||
import sys
|
||||
import pythoncom
|
||||
if 'pywinauto' not in sys.modules:
|
||||
# Match the real worker's STA apartment. pywinauto's first import probes
|
||||
# MTA and may report its fallback; validate that exact diagnostic only.
|
||||
import warnings
|
||||
pythoncom.CoInitializeEx(pythoncom.COINIT_APARTMENTTHREADED)
|
||||
try:
|
||||
with warnings.catch_warnings(record=True) as diagnostics:
|
||||
warnings.simplefilter('always')
|
||||
from pywinauto import Desktop
|
||||
for diagnostic in diagnostics:
|
||||
if diagnostic.category is UserWarning and str(diagnostic.message) in (
|
||||
'Revert to STA COM threading mode', 'Apply externally defined coinit_flags: 2'):
|
||||
assert sys.coinit_flags == pythoncom.COINIT_APARTMENTTHREADED
|
||||
else:
|
||||
warnings.warn_explicit(diagnostic.message, diagnostic.category,
|
||||
diagnostic.filename, diagnostic.lineno)
|
||||
finally:
|
||||
pythoncom.CoUninitialize()
|
||||
else:
|
||||
from pywinauto import Desktop
|
||||
monkeypatch.setattr(Desktop, 'windows', lambda *_: [])
|
||||
|
||||
closed = []
|
||||
|
||||
Reference in new issue
Block a user