From ddfc4d378f4a630931f22e08d6fb1474993f838b Mon Sep 17 00:00:00 2001 From: Ales Erjavec Date: Thu, 15 Feb 2024 11:39:17 +0100 Subject: [PATCH] test_owcsvimport: Remove create_widget override Avoid possible double memory reclamation --- Orange/widgets/data/tests/test_owcsvimport.py | 21 ++++--------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/Orange/widgets/data/tests/test_owcsvimport.py b/Orange/widgets/data/tests/test_owcsvimport.py index 8988b7ec372..771bb528b39 100644 --- a/Orange/widgets/data/tests/test_owcsvimport.py +++ b/Orange/widgets/data/tests/test_owcsvimport.py @@ -35,23 +35,6 @@ class TestOWCSVFileImport(WidgetTest): - def create_widget( - self, cls: Type[W], stored_settings: Optional[dict] = None, - reset_default_settings=True, **kwargs) -> W: - if reset_default_settings: - self.reset_default_settings(cls) - widget = cls.__new__(cls, signal_manager=self.signal_manager, - stored_settings=stored_settings, **kwargs) - widget.__init__() - - def delete(): - widget.onDeleteWidget() - widget.close() - widget.deleteLater() - - self._stack.callback(delete) - return widget - def setUp(self): super().setUp() self._stack = ExitStack().__enter__() @@ -293,6 +276,7 @@ def test_browse_for_missing(self): widget.activate_recent(0) dlg = widget.findChild(QFileDialog) assert dlg is not None + dlg.setParent(None) # calling selectFile when using native (macOS) dialog does not have # an effect - at least not immediately; dlg.setOption(QFileDialog.DontUseNativeDialog) @@ -303,6 +287,7 @@ def test_browse_for_missing(self): self.assertEqual( self.data_regions_options.as_dict(), cur.options().as_dict() ) + dlg.deleteLater() def test_browse_for_missing_prefixed(self): path = self.data_regions_path @@ -349,6 +334,7 @@ def test_browse_for_missing_prefixed_parent(self): widget.activate_recent(0) dlg = widget.findChild(QFileDialog) assert dlg is not None + dlg.setParent(None) # calling selectFile when using native (macOS) dialog does not have # an effect - at least not immediately; dlg.setOption(QFileDialog.DontUseNativeDialog) @@ -358,6 +344,7 @@ def test_browse_for_missing_prefixed_parent(self): cur = widget.current_item() self.assertEqual(item[0], cur.varPath()) self.assertEqual(item[1].as_dict(), cur.options().as_dict()) + dlg.deleteLater() class TestImportDialog(GuiTest):