<div dir="ltr"><div>Hello,</div><div><br></div><div>I'm trying to establish a Python test methodology whereby a QApplication is launched (and its event loop executed) in a secondary thread, while the primary thread performs some "test scenario".</div><div>Summary: I'm unable to set this up, and it isn't clear why this isn't working.</div><div><br></div><div>Details: please consider the attached test file (executed with `pytest -vs qt-minimal-test,py`).<br></div><div><br></div><div>In this minimal test case, the actual test function body is empty. A "fixture" function is used to set up the system, i.e. launch a thread to construct the application showing only a "quit" button.<br></div><div><br></div><div>Consider these cases:</div><div><br></div><div>0. run the above command, wait for the test passing being reported on the console, then click the "quit" button. This appears to be working as expected.</div><div><br></div><div>1. run the above command, but click the "quit" button immediately. Thus results in the error message `<span style="font-family:monospace"><span style="color:rgb(0,0,0);background-color:rgb(255,255,255)">QObject::killTimer: Timers cannot be stopped from another thread`,</span><br></span></div><div><span style="font-family:monospace">
followed by a segmentation fault<br></span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">2. rather than just "yielding" to the test function, yield the application object (so the test function can interact with it). No matter when you click the "quit" button, the result is the same as in 1.</span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">3. call `h.app.quit()` after he `yield` (i.e. as soon as the test function completes). Result: the application becomes unresponsive, but doesn't stop</span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">Any idea why the above happens ?<br></span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">Many thanks for any help you can offer !<br></span></div><div><br></div><div><br></div><div><br><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><img src="https://ci3.googleusercontent.com/mail-sig/AIorK4yh4RzsqlxV6irScDGRVZ8a7NRCh_INtpPsAHx2Y8v4Vu3VKsI54RFNs3YRZk_2xTTtMMdSCzdNrf5XRUlmF4BkezmtZv-j5c3A4G0hEA"></div><div><pre> ...ich hab' noch einen Koffer in Berlin...
</pre></div></div></div></div></div>