From f2c5f72c9982b7642d8c3a61ad4f5849a4dc0355 Mon Sep 17 00:00:00 2001 From: Vesna Tanko Date: Thu, 3 Nov 2016 14:39:19 +0100 Subject: [PATCH] OWDataSampler: Do not show messages when data is removed --- Orange/widgets/data/owdatasampler.py | 1 + .../widgets/data/tests/test_owdatasampler.py | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 Orange/widgets/data/tests/test_owdatasampler.py diff --git a/Orange/widgets/data/owdatasampler.py b/Orange/widgets/data/owdatasampler.py index 7f5eaae3973..2d6bf3e07c8 100644 --- a/Orange/widgets/data/owdatasampler.py +++ b/Orange/widgets/data/owdatasampler.py @@ -175,6 +175,7 @@ def set_data(self, dataset): self.dataInfoLabel.setText('No data on input.') self.outputInfoLabel.setText('') self.indices = None + self.clear_messages() self.commit() def commit(self): diff --git a/Orange/widgets/data/tests/test_owdatasampler.py b/Orange/widgets/data/tests/test_owdatasampler.py new file mode 100644 index 00000000000..471a9687199 --- /dev/null +++ b/Orange/widgets/data/tests/test_owdatasampler.py @@ -0,0 +1,27 @@ +# Test methods with long descriptive names can omit docstrings +# pylint: disable=missing-docstring +from Orange.data import Table +from Orange.widgets.data.owdatasampler import OWDataSampler +from Orange.widgets.tests.base import WidgetTest + + +class TestOWDataSampler(WidgetTest): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.iris = Table("iris") + + def setUp(self): + self.widget = self.create_widget(OWDataSampler) + + def test_error_message(self): + """ Check if error message appears and then disappears when + data is removed from input""" + self.widget.controlledAttributes["sampling_type"][0].control.buttons[ + 2].click() + self.send_signal("Data", self.iris) + self.assertFalse(self.widget.Error.too_many_folds.is_shown()) + self.send_signal("Data", self.iris[:5]) + self.assertTrue(self.widget.Error.too_many_folds.is_shown()) + self.send_signal("Data", None) + self.assertFalse(self.widget.Error.too_many_folds.is_shown())