Q Expect an analog in PySide?

I wrote a series of unit tests in PyQt using QTest and unittest. My code passes signals around, so in order to provide enough time after the operation before testing, I throw some qWaits.

APP.ui.serverPortEdit.setText('1234') QTest.mouseClick(APP.ui.userConnectButton, Qt.LeftButton) QTest.qWait(2000) #wait for the server to connect self.checkOnline() 

I would like to run the same tests in PySide, but I can not find an analog for qWait. Am I missing something? PySide qTest docs does not mention this.

+4
source share
2 answers

Can't you use python time.sleep ()?

+2
source

For others that come across this (my first google hit) time.sleep() does not handle QEvent s. I came across this PyQt4 / PySide shell , which defines qWait for use with PySide:

 from datetime import datetime as datetime_, timedelta @staticmethod def qWait(t): end = datetime_.now() + timedelta(milliseconds=t) while datetime_.now() < end: QtGui.QApplication.processEvents() QtTest.QTest.qWait = qWait 
+1
source

Source: https://habr.com/ru/post/1494395/


All Articles