def test_find_widget(self): dialog = Dialog() tester = ModalDialogTester(dialog.open) def check_and_close(tester): try: with tester.capture_error(): widget = tester.find_qt_widget( type_=QtGui.QAbstractButton, test=lambda x: x.text() == 'OK') self.assertIsInstance(widget, QtGui.QPushButton) finally: tester.close() tester.open_and_run(when_opened=check_and_close)
def test_has_widget(self): dialog = Dialog() tester = ModalDialogTester(dialog.open) def check_and_close(tester): try: with tester.capture_error(): self.assertTrue( tester.has_widget('OK', QtGui.QAbstractButton)) self.assertFalse( tester.has_widget(text='I am a virtual button')) finally: tester.close() tester.open_and_run(when_opened=check_and_close)