python - Keeping a dialog from showing PySide for testing -
i'm writing test functions form made. there couple of qmessagebox invoked(one through qmessagebox.question method , 1 through qmessagebox.information method. while custom widget not shown on screen, these 2 show on screen.
i tried dismissing them looping through widgets in qapplication.toplevelwidgets() , dismissing right one, however, seems code continues executing after manually dismiss messagebox.
so question two-fold:
1) how maintain qmessagebox (or widget really) showing on screen during testing.
2) how can programmatically accept/reject/dismiss widget.
you can set timer automatically take dialog. if timeout long, dialog still display while:
w = qtgui.qdialog(none) t = qtcore.qtimer(none) t.timeout.connect(w.accept) t.start(1) w.exec_()
for specific case, if don't want touch code beingness testes, can have timer run function take current modal widgets, suggesting:
def accept_all(): wid in app.toplevelwidgets(): if wid.__class__ == qtgui.qdialog: #or qmessagebox, etc: wid.accept() t = qtcore.qtimer(none) t.timeout.connect(accept_all) t.start(10)
python qt unit-testing pyqt pyside
No comments:
Post a Comment