calumroy / HTM

HTM
3 stars 0 forks source link

Pause and load the GUI in a test. #16

Closed calumroy closed 9 years ago

calumroy commented 9 years ago

Within the nosetests the HTM GUI can be loaded and halt the testing. This can be very useful to see what is happening in the HTM network during a test. Use the following code inserted into the test

app = QtGui.QApplication(sys.argv)
self.htmGui = GUI_HTM.HTMGui(self.htm, self.InputCreator)
sys.exit(app.exec_())

Note this doesn't allow you to return back to the test and as a result the test states it failed.

calumroy commented 9 years ago

Use this instead so the GUI can be loaded quitted and reloaded. This is especially useful to open the GUI up during a test to check that the test is designed correctly.

app = QtGui.QApplication.instance()  # checks if QApplication already exists
if not app:  # create QApplication if it doesnt exist
    app = QtGui.QApplication(sys.argv)
app.aboutToQuit.connect(app.deleteLater)
self.htmGui = GUI_HTM.HTMGui(self.htm, self.InputCreator)
app.exec_()