Skip to content

Commit 2761ff1

Browse files
committed
owcsvimport: Add test_browse_for_missing_prefixed_parent test
1 parent d4b2a5f commit 2761ff1

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

Orange/widgets/data/tests/test_owcsvimport.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,33 @@ def test_browse_for_missing_prefixed(self):
296296
self.data_regions_options.as_dict(), cur.options().as_dict()
297297
)
298298

299+
def test_browse_for_missing_prefixed_parent(self):
300+
path = self.data_regions_path
301+
basedir = os.path.join(os.path.dirname(path), "origin1")
302+
item = (PathItem.VarPath("basedir",
303+
"this file does not exist.csv"),
304+
self.data_regions_options)
305+
widget = self.create_widget(
306+
owcsvimport.OWCSVFileImport, stored_settings={
307+
"__version__": 2,
308+
"_session_items_v2": [(item[0].as_dict(), item[1].as_dict())]
309+
},
310+
env={"basedir": basedir}
311+
)
312+
mb = widget._path_must_be_relative_mb = mock.Mock()
313+
widget.activate_recent(0)
314+
dlg = widget.findChild(QFileDialog)
315+
assert dlg is not None
316+
# calling selectFile when using native (macOS) dialog does not have
317+
# an effect - at least not immediately;
318+
dlg.setOption(QFileDialog.DontUseNativeDialog)
319+
dlg.selectFile(path)
320+
dlg.accept()
321+
mb.assert_called()
322+
cur = widget.current_item()
323+
self.assertEqual(item[0], cur.varPath())
324+
self.assertEqual(item[1].as_dict(), cur.options().as_dict())
325+
299326

300327
class TestImportDialog(GuiTest):
301328
def test_dialog(self):

0 commit comments

Comments
 (0)