From 4b7c66e796b66df8d85c31a82b912f9ba3ca5c6a Mon Sep 17 00:00:00 2001 From: Rafael Irgolic Date: Thu, 5 Aug 2021 01:41:05 +0100 Subject: [PATCH] test_owcsvimport: Fixup tests --- Orange/widgets/data/tests/test_owcsvimport.py | 25 ++++++------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/Orange/widgets/data/tests/test_owcsvimport.py b/Orange/widgets/data/tests/test_owcsvimport.py index 721e923d66b..5ce85a295f0 100644 --- a/Orange/widgets/data/tests/test_owcsvimport.py +++ b/Orange/widgets/data/tests/test_owcsvimport.py @@ -76,7 +76,7 @@ def test_basic(self): data_regions_options = owcsvimport.Options( encoding="ascii", dialect=csv.excel_tab(), columntypes=[ - (range(0, 1), ColumnType.Categorical), + (range(0, 1), ColumnType.Numeric), (range(1, 2), ColumnType.Text), (range(2, 3), ColumnType.Categorical), ], rowspec=[ @@ -90,10 +90,10 @@ def test_basic(self): def _check_data_regions(self, table): self.assertEqual(len(table), 3) self.assertEqual(len(table), 3) - self.assertTrue(table.domain["id"].is_discrete) + self.assertTrue(table.domain["id"].is_continuous) self.assertTrue(table.domain["continent"].is_discrete) self.assertTrue(table.domain["state"].is_string) - assert_array_equal(table.X, [[0, 1], [1, 1], [2, 0]]) + assert_array_equal(table.X, [[1, 1], [2, 1], [3, 0]]) assert_array_equal(table.metas, np.array([["UK"], ["Russia"], ["Mexico"]], object)) @@ -253,34 +253,22 @@ def test_browse(self): cur = widget.current_item() self.assertIsNotNone(cur) self.assertTrue(samepath(cur.path(), path)) + self.assertIsInstance(cur.varPath(), PathItem.AbsPath) - def test_browse_prefix(self): + def test_browse_relative(self): widget = self.widget path = self.data_regions_path with self._browse_setup(widget, path): basedir = os.path.dirname(__file__) widget.workflowEnv = lambda: {"basedir": basedir} widget.workflowEnvChanged("basedir", basedir, "") - widget.browse_relative(prefixname="basedir") + widget.browse() cur = widget.current_item() self.assertIsNotNone(cur) self.assertTrue(samepath(cur.path(), path)) self.assertIsInstance(cur.varPath(), PathItem.VarPath) - def test_browse_prefix_parent(self): - widget = self.widget - path = self.data_regions_path - - with self._browse_setup(widget, path): - basedir = os.path.join(os.path.dirname(__file__), "bs") - widget.workflowEnv = lambda: {"basedir": basedir} - widget.workflowEnvChanged("basedir", basedir, "") - mb = widget._path_must_be_relative_mb = mock.Mock() - widget.browse_relative(prefixname="basedir") - mb.assert_called() - self.assertIsNone(widget.current_item()) - def test_browse_for_missing(self): missing = os.path.dirname(__file__) + "/this file does not exist.csv" widget = self.create_widget( @@ -375,6 +363,7 @@ def test_unsafe_cast_warning(self): self.process_events(until=lambda: w.data is not None) index = w.domain_editor.model().index(0, 1) w.domain_editor.model().setData(index, 'text') + w.apply_domain_edit() self.assertTrue(w.Warning.numeric_cast.is_shown())