diff --git a/Orange/widgets/tests/base.py b/Orange/widgets/tests/base.py index 8e07cb0f9d6..89b156e41f7 100644 --- a/Orange/widgets/tests/base.py +++ b/Orange/widgets/tests/base.py @@ -967,15 +967,17 @@ def test_plot_once(self, timeout=DEFAULT_TIMEOUT): self.widget.setup_plot = Mock() self.widget.commit = Mock() self.send_signal(self.widget.Inputs.data, table) - self.widget.setup_plot.assert_called_once() - self.widget.commit.assert_called_once() - if self.widget.isBlocking(): spy = QSignalSpy(self.widget.blockingStateChanged) self.assertTrue(spy.wait(timeout)) + self.widget.setup_plot.assert_called_once() + self.widget.commit.assert_called_once() self.widget.commit.reset_mock() self.send_signal(self.widget.Inputs.data_subset, table[::10]) + if self.widget.isBlocking(): + spy = QSignalSpy(self.widget.blockingStateChanged) + self.assertTrue(spy.wait(timeout)) self.widget.setup_plot.assert_called_once() self.widget.commit.assert_called_once() diff --git a/Orange/widgets/unsupervised/tests/test_owmds.py b/Orange/widgets/unsupervised/tests/test_owmds.py index 01a1a914172..2a3c95bfd7e 100644 --- a/Orange/widgets/unsupervised/tests/test_owmds.py +++ b/Orange/widgets/unsupervised/tests/test_owmds.py @@ -49,6 +49,23 @@ def tearDown(self): self.widget.onDeleteWidget() super().tearDown() + def test_plot_once(self, timeout=5000): + """Test if data is plotted only once but committed on every input change""" + table = Table("heart_disease") + self.widget.setup_plot = Mock() + self.widget.commit = Mock() + self.send_signal(self.widget.Inputs.data, table) + self.widget.commit.reset_mock() + self.wait_until_stop_blocking() + self.widget.setup_plot.assert_called_once() + self.widget.commit.assert_called_once() + + self.widget.commit.reset_mock() + self.send_signal(self.widget.Inputs.data_subset, table[::10]) + self.wait_until_stop_blocking() + self.widget.setup_plot.assert_called_once() + self.widget.commit.assert_called_once() + def test_pca_init(self): self.send_signal(self.signal_name, self.signal_data) output = self.get_output(self.widget.Outputs.annotated_data, wait=1000)