def testUnload(self): """check if plugin unload is correctly executed. That means, menu remove is called and deleted relative QAction.""" # preconditions testerPlugin = TesterPlugin(self.IFACE_Mock) action = QtGui.QAction("Start testing", self.IFACE_Mock.mainWindow()) testerPlugin.action = action # do test 1) widget is None self.IFACE_Mock.reset_mock() testerPlugin.unload() self.assertIn("call.removePluginMenu(u'Tester'", str(self.IFACE_Mock.mock_calls[-1])) self.assertNotIn('action', testerPlugin.__dict__) self.assertIn('widget', testerPlugin.__dict__) # preconditions testerPlugin = TesterPlugin(self.IFACE_Mock) action = QtGui.QAction("Start testing", self.IFACE_Mock.mainWindow()) testerPlugin.action = action # do test 2) widget is available self.IFACE_Mock.reset_mock() testerPlugin.widget = mock.MagicMock(QtGui.QWidget) testerPlugin.unload() self.assertIn("call.removePluginMenu(u'Tester'", str(self.IFACE_Mock.mock_calls[0])) self.assertNotIn('action', testerPlugin.__dict__) self.assertNotIn('widget', testerPlugin.__dict__)
def testUnload(self): """check if plugin unload is correctly executed. That means, menu remove is called and deleted relative QAction.""" # preconditions testerPlugin = TesterPlugin(self.IFACE_Mock) action = QAction("Start testing", self.IFACE_Mock.mainWindow()) testerPlugin.action = action # do test 1) widget is None self.IFACE_Mock.reset_mock() testerPlugin.unload() if isPyQt4: self.assertIn("call.removePluginMenu(u'Tester'", str(self.IFACE_Mock.mock_calls[-1])) else: self.assertIn("call.removePluginMenu('Tester'", str(self.IFACE_Mock.mock_calls[-1])) self.assertNotIn('action', testerPlugin.__dict__) self.assertIn('widget', testerPlugin.__dict__) # preconditions testerPlugin = TesterPlugin(self.IFACE_Mock) action = QAction("Start testing", self.IFACE_Mock.mainWindow()) testerPlugin.action = action # do test 2) widget is available self.IFACE_Mock.reset_mock() testerPlugin.widget = mock.MagicMock(QWidget) testerPlugin.unload() if isPyQt4: self.assertIn("call.removePluginMenu(u'Tester'", str(self.IFACE_Mock.mock_calls[0])) else: self.assertIn("call.removePluginMenu('Tester'", str(self.IFACE_Mock.mock_calls[0])) self.assertNotIn('action', testerPlugin.__dict__) self.assertNotIn('widget', testerPlugin.__dict__)
def testUnload(self): """Check that the plugin unloaded correctly""" testerPlugin = TesterPlugin(self.IFACE_Mock) action = QAction('Start testing', self.IFACE_Mock.mainWindow()) actionHelp = QAction('Help', self.IFACE_Mock.mainWindow()) actionAbout = QAction('About…', self.IFACE_Mock.mainWindow()) testerPlugin.action = action testerPlugin.actionHelp = actionHelp testerPlugin.actionAbout = actionAbout testerPlugin.widget = mock.MagicMock(QWidget) self.IFACE_Mock.reset_mock() testerPlugin.unload() self.assertEqual(len(self.IFACE_Mock.mock_calls), 3) self.assertNotIn('widget', testerPlugin.__dict__)