def test_closeEvent(self): self.view.findChildren = mock.Mock() c1 = mock.Mock() c2 = mock.Mock() c3 = mock.Mock() self.view.findChildren.return_value = [c1, c2] self.view.closeEvent(QCloseEvent()) c1.close.assert_called_once() c2.close.assert_called_once() c3.close.assert_not_called()
def test_that_closing_with_a_plot_will_close_the_window(self): self.gui.plot_window = mock.create_autospec(MultiPlotWindow) self.gui.closeEvent(QCloseEvent()) self.assertEqual(self.gui.plot_window.closeEvent.call_count, 1)
def test_that_closing_with_no_plot_will_not_throw(self): self.gui.plot_window = None assertRaisesNothing(self, self.gui.closeEvent, QCloseEvent())