diff options
author | Alexandre Marie <alexandre.marie@synchrotron-soleil.fr> | 2018-12-17 12:28:24 +0100 |
---|---|---|
committer | Alexandre Marie <alexandre.marie@synchrotron-soleil.fr> | 2018-12-17 12:28:24 +0100 |
commit | cebdc9244c019224846cb8d2668080fe386a6adc (patch) | |
tree | aedec55da0f9dd4fc4d6c7eb0f58489a956e2e8c /silx/gui/dialog | |
parent | 159ef14fb9e198bb0066ea14e6b980f065de63dd (diff) |
New upstream version 0.9.0+dfsg
Diffstat (limited to 'silx/gui/dialog')
-rw-r--r-- | silx/gui/dialog/AbstractDataFileDialog.py | 2 | ||||
-rw-r--r-- | silx/gui/dialog/ColormapDialog.py | 5 | ||||
-rw-r--r-- | silx/gui/dialog/DatasetDialog.py | 122 | ||||
-rw-r--r-- | silx/gui/dialog/GroupDialog.py | 161 | ||||
-rw-r--r-- | silx/gui/dialog/SafeFileIconProvider.py | 4 | ||||
-rw-r--r-- | silx/gui/dialog/SafeFileSystemModel.py | 2 | ||||
-rw-r--r-- | silx/gui/dialog/test/test_colormapdialog.py | 4 | ||||
-rw-r--r-- | silx/gui/dialog/test/test_datafiledialog.py | 120 | ||||
-rw-r--r-- | silx/gui/dialog/test/test_imagefiledialog.py | 86 |
9 files changed, 341 insertions, 165 deletions
diff --git a/silx/gui/dialog/AbstractDataFileDialog.py b/silx/gui/dialog/AbstractDataFileDialog.py index cb6711c..40045fe 100644 --- a/silx/gui/dialog/AbstractDataFileDialog.py +++ b/silx/gui/dialog/AbstractDataFileDialog.py @@ -1170,7 +1170,7 @@ class AbstractDataFileDialog(qt.QDialog): def __filterSelected(self, index): filters = self.__fileTypeCombo.itemExtensions(index) - self.__fileModel.setNameFilters(filters) + self.__fileModel.setNameFilters(list(filters)) def __setData(self, data): self.__data = data diff --git a/silx/gui/dialog/ColormapDialog.py b/silx/gui/dialog/ColormapDialog.py index ed10728..cbbfa5a 100644 --- a/silx/gui/dialog/ColormapDialog.py +++ b/silx/gui/dialog/ColormapDialog.py @@ -710,8 +710,9 @@ class ColormapDialog(qt.QDialog): self._updateMinMaxData() def getColormap(self): - """Return the colormap description as a :class:`.Colormap`. + """Return the colormap description. + :rtype: ~silx.gui.colors.Colormap """ if self._colormap is None: return None @@ -811,7 +812,7 @@ class ColormapDialog(qt.QDialog): def setColormap(self, colormap): """Set the colormap description - :param :class:`Colormap` colormap: the colormap to edit + :param ~silx.gui.colors.Colormap colormap: the colormap to edit """ assert colormap is None or isinstance(colormap, Colormap) if self._ignoreColormapChange is True: diff --git a/silx/gui/dialog/DatasetDialog.py b/silx/gui/dialog/DatasetDialog.py new file mode 100644 index 0000000..87fc89d --- /dev/null +++ b/silx/gui/dialog/DatasetDialog.py @@ -0,0 +1,122 @@ +# coding: utf-8 +# /*########################################################################## +# +# Copyright (c) 2018 European Synchrotron Radiation Facility +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# +# ###########################################################################*/ +"""This module provides a dialog widget to select a HDF5 dataset in a +tree. + +.. autoclass:: DatasetDialog + :members: addFile, addGroup, getSelectedDataUrl, setMode + +""" +from .GroupDialog import _Hdf5ItemSelectionDialog +import silx.io +from silx.io.url import DataUrl + + +__authors__ = ["P. Knobel"] +__license__ = "MIT" +__date__ = "05/09/2018" + + +class DatasetDialog(_Hdf5ItemSelectionDialog): + """This :class:`QDialog` uses a :class:`silx.gui.hdf5.Hdf5TreeView` to + provide a HDF5 dataset selection dialog. + + The information identifying the selected node is provided as a + :class:`silx.io.url.DataUrl`. + + Example: + + .. code-block:: python + + dialog = DatasetDialog() + dialog.addFile(filepath1) + dialog.addFile(filepath2) + + if dialog.exec_(): + print("File path: %s" % dialog.getSelectedDataUrl().file_path()) + print("HDF5 dataset path : %s " % dialog.getSelectedDataUrl().data_path()) + else: + print("Operation cancelled :(") + + """ + def __init__(self, parent=None): + _Hdf5ItemSelectionDialog.__init__(self, parent) + + # customization for groups + self.setWindowTitle("HDF5 dataset selection") + + self._header.setSections([self._model.NAME_COLUMN, + self._model.NODE_COLUMN, + self._model.LINK_COLUMN, + self._model.TYPE_COLUMN, + self._model.SHAPE_COLUMN]) + self._selectDatasetStatusText = "Select a dataset or type a new dataset name" + + def setMode(self, mode): + """Set dialog mode DatasetDialog.SaveMode or DatasetDialog.LoadMode + + :param mode: DatasetDialog.SaveMode or DatasetDialog.LoadMode + """ + _Hdf5ItemSelectionDialog.setMode(self, mode) + if mode == DatasetDialog.SaveMode: + self._selectDatasetStatusText = "Select a dataset or type a new dataset name" + elif mode == DatasetDialog.LoadMode: + self._selectDatasetStatusText = "Select a dataset" + + def _onActivation(self, idx): + # double-click or enter press: filter for datasets + nodes = list(self._tree.selectedH5Nodes()) + node = nodes[0] + if silx.io.is_dataset(node.h5py_object): + self.accept() + + def _updateUrl(self): + # overloaded to filter for datasets + nodes = list(self._tree.selectedH5Nodes()) + newDatasetName = self._lineEditNewItem.text() + isDatasetSelected = False + if nodes: + node = nodes[0] + if silx.io.is_dataset(node.h5py_object): + data_path = node.local_name + isDatasetSelected = True + elif silx.io.is_group(node.h5py_object): + data_path = node.local_name + if newDatasetName.lstrip("/"): + if not data_path.endswith("/"): + data_path += "/" + data_path += newDatasetName.lstrip("/") + isDatasetSelected = True + + if isDatasetSelected: + self._selectedUrl = DataUrl(file_path=node.local_filename, + data_path=data_path) + self._okButton.setEnabled(True) + self._labelSelection.setText( + self._selectedUrl.path()) + else: + self._selectedUrl = None + self._okButton.setEnabled(False) + self._labelSelection.setText(self._selectDatasetStatusText) diff --git a/silx/gui/dialog/GroupDialog.py b/silx/gui/dialog/GroupDialog.py index 71235d2..217a03c 100644 --- a/silx/gui/dialog/GroupDialog.py +++ b/silx/gui/dialog/GroupDialog.py @@ -26,9 +26,7 @@ tree. .. autoclass:: GroupDialog - :show-inheritance: - :members: - + :members: addFile, addGroup, getSelectedDataUrl, setMode """ from silx.gui import qt @@ -41,31 +39,18 @@ __license__ = "MIT" __date__ = "22/03/2018" -class GroupDialog(qt.QDialog): - """This :class:`QDialog` uses a :class:`silx.gui.hdf5.Hdf5TreeView` to - provide a HDF5 group selection dialog. - - The information identifying the selected node is provided as a - :class:`silx.io.url.DataUrl`. - - Example: - - .. code-block:: python - - dialog = GroupDialog() - dialog.addFile(filepath1) - dialog.addFile(filepath2) +class _Hdf5ItemSelectionDialog(qt.QDialog): + SaveMode = 1 + """Mode used to set the HDF5 item selection dialog to *save* mode. + This adds a text field to type in a new item name.""" - if dialog.exec_(): - print("File path: %s" % dialog.getSelectedDataUrl().file_path()) - print("HDF5 group path : %s " % dialog.getSelectedDataUrl().data_path()) - else: - print("Operation cancelled :(") + LoadMode = 2 + """Mode used to set the HDF5 item selection dialog to *load* mode. + Only existing items of the HDF5 file can be selected in this mode.""" - """ def __init__(self, parent=None): qt.QDialog.__init__(self, parent) - self.setWindowTitle("HDF5 group selection") + self.setWindowTitle("HDF5 item selection") self._tree = Hdf5TreeView(self) self._tree.setSelectionMode(qt.QAbstractItemView.SingleSelection) @@ -76,25 +61,26 @@ class GroupDialog(qt.QDialog): self._model = self._tree.findHdf5TreeModel() self._header = self._tree.header() - self._header.setSections([self._model.NAME_COLUMN, - self._model.NODE_COLUMN, - self._model.LINK_COLUMN]) - _labelSubgroup = qt.QLabel(self) - _labelSubgroup.setText("Subgroup name (optional)") - self._lineEditSubgroup = qt.QLineEdit(self) - self._lineEditSubgroup.setToolTip( - "Specify the name of a new subgroup " + self._newItemWidget = qt.QWidget(self) + newItemLayout = qt.QVBoxLayout(self._newItemWidget) + self._labelNewItem = qt.QLabel(self._newItemWidget) + self._labelNewItem.setText("Create new item in selected group (optional):") + self._lineEditNewItem = qt.QLineEdit(self._newItemWidget) + self._lineEditNewItem.setToolTip( + "Specify the name of a new item " "to be created in the selected group.") - self._lineEditSubgroup.textChanged.connect( - self._onSubgroupNameChange) + self._lineEditNewItem.textChanged.connect( + self._onNewItemNameChange) + newItemLayout.addWidget(self._labelNewItem) + newItemLayout.addWidget(self._lineEditNewItem) _labelSelectionTitle = qt.QLabel(self) _labelSelectionTitle.setText("Current selection") self._labelSelection = qt.QLabel(self) self._labelSelection.setStyleSheet("color: gray") self._labelSelection.setWordWrap(True) - self._labelSelection.setText("Select a group") + self._labelSelection.setText("Select an item") buttonBox = qt.QDialogButtonBox() self._okButton = buttonBox.addButton(qt.QDialogButtonBox.Ok) @@ -106,8 +92,7 @@ class GroupDialog(qt.QDialog): vlayout = qt.QVBoxLayout(self) vlayout.addWidget(self._tree) - vlayout.addWidget(_labelSubgroup) - vlayout.addWidget(self._lineEditSubgroup) + vlayout.addWidget(self._newItemWidget) vlayout.addWidget(_labelSelectionTitle) vlayout.addWidget(self._labelSelection) vlayout.addWidget(buttonBox) @@ -117,6 +102,30 @@ class GroupDialog(qt.QDialog): self._selectedUrl = None + def _onSelectionChange(self, old, new): + self._updateUrl() + + def _onNewItemNameChange(self, text): + self._updateUrl() + + def _onActivation(self, idx): + # double-click or enter press + self.accept() + + def setMode(self, mode): + """Set dialog mode DatasetDialog.SaveMode or DatasetDialog.LoadMode + + :param mode: DatasetDialog.SaveMode or DatasetDialog.LoadMode + """ + if mode == self.LoadMode: + # hide "Create new item" field + self._lineEditNewItem.clear() + self._newItemWidget.hide() + elif mode == self.SaveMode: + self._newItemWidget.show() + else: + raise ValueError("Invalid DatasetDialog mode %s" % mode) + def addFile(self, path): """Add a HDF5 file to the tree. All groups it contains will be selectable in the dialog. @@ -133,22 +142,75 @@ class GroupDialog(qt.QDialog): """ self._model.insertH5pyObject(group) + def _updateUrl(self): + nodes = list(self._tree.selectedH5Nodes()) + subgroupName = self._lineEditNewItem.text() + if nodes: + node = nodes[0] + data_path = node.local_name + if subgroupName.lstrip("/"): + if not data_path.endswith("/"): + data_path += "/" + data_path += subgroupName.lstrip("/") + self._selectedUrl = DataUrl(file_path=node.local_filename, + data_path=data_path) + self._okButton.setEnabled(True) + self._labelSelection.setText( + self._selectedUrl.path()) + + def getSelectedDataUrl(self): + """Return a :class:`DataUrl` with a file path and a data path. + Return None if the dialog was cancelled. + + :return: :class:`silx.io.url.DataUrl` object pointing to the + selected HDF5 item. + """ + return self._selectedUrl + + +class GroupDialog(_Hdf5ItemSelectionDialog): + """This :class:`QDialog` uses a :class:`silx.gui.hdf5.Hdf5TreeView` to + provide a HDF5 group selection dialog. + + The information identifying the selected node is provided as a + :class:`silx.io.url.DataUrl`. + + Example: + + .. code-block:: python + + dialog = GroupDialog() + dialog.addFile(filepath1) + dialog.addFile(filepath2) + + if dialog.exec_(): + print("File path: %s" % dialog.getSelectedDataUrl().file_path()) + print("HDF5 group path : %s " % dialog.getSelectedDataUrl().data_path()) + else: + print("Operation cancelled :(") + + """ + def __init__(self, parent=None): + _Hdf5ItemSelectionDialog.__init__(self, parent) + + # customization for groups + self.setWindowTitle("HDF5 group selection") + + self._header.setSections([self._model.NAME_COLUMN, + self._model.NODE_COLUMN, + self._model.LINK_COLUMN]) + def _onActivation(self, idx): - # double-click or enter press + # double-click or enter press: filter for groups nodes = list(self._tree.selectedH5Nodes()) node = nodes[0] if silx.io.is_group(node.h5py_object): self.accept() - def _onSelectionChange(self, old, new): - self._updateUrl() - - def _onSubgroupNameChange(self, text): - self._updateUrl() - def _updateUrl(self): + # overloaded to filter for groups nodes = list(self._tree.selectedH5Nodes()) - subgroupName = self._lineEditSubgroup.text() + subgroupName = self._lineEditNewItem.text() if nodes: node = nodes[0] if silx.io.is_group(node.h5py_object): @@ -166,12 +228,3 @@ class GroupDialog(qt.QDialog): self._selectedUrl = None self._okButton.setEnabled(False) self._labelSelection.setText("Select a group") - - def getSelectedDataUrl(self): - """Return a :class:`DataUrl` with a file path and a data path. - Return None if the dialog was cancelled. - - :return: :class:`silx.io.url.DataUrl` object pointing to the - selected group. - """ - return self._selectedUrl diff --git a/silx/gui/dialog/SafeFileIconProvider.py b/silx/gui/dialog/SafeFileIconProvider.py index 7fac7c0..1e06b64 100644 --- a/silx/gui/dialog/SafeFileIconProvider.py +++ b/silx/gui/dialog/SafeFileIconProvider.py @@ -115,6 +115,10 @@ class SafeFileIconProvider(qt.QFileIconProvider): return driveInfo[0] def icon(self, info): + if isinstance(info, qt.QFileIconProvider.IconType): + # It's another C++ method signature: + # QIcon QFileIconProvider::icon(QFileIconProvider::IconType type) + return super(SafeFileIconProvider, self).icon(info) style = qt.QApplication.instance().style() path = info.filePath() if path in ["", "/"]: diff --git a/silx/gui/dialog/SafeFileSystemModel.py b/silx/gui/dialog/SafeFileSystemModel.py index 8a97974..198e089 100644 --- a/silx/gui/dialog/SafeFileSystemModel.py +++ b/silx/gui/dialog/SafeFileSystemModel.py @@ -749,7 +749,7 @@ class SafeFileSystemModel(qt.QSortFilterProxyModel): index = self.mapToSource(index) filters = sourceModel.flags(index) - if self.__nameFilterDisables: + if self.__nameFilterDisables and not sourceModel.isDir(index): item = sourceModel._item(index) if not self.__nameFiltersAccepted(item): filters &= ~qt.Qt.ItemIsEnabled diff --git a/silx/gui/dialog/test/test_colormapdialog.py b/silx/gui/dialog/test/test_colormapdialog.py index 6f0ceea..6e50193 100644 --- a/silx/gui/dialog/test/test_colormapdialog.py +++ b/silx/gui/dialog/test/test_colormapdialog.py @@ -32,10 +32,10 @@ __date__ = "23/05/2018" import doctest import unittest -from silx.gui.test.utils import qWaitForWindowExposedAndActivate +from silx.gui.utils.testutils import qWaitForWindowExposedAndActivate from silx.gui import qt from silx.gui.dialog import ColormapDialog -from silx.gui.test.utils import TestCaseQt +from silx.gui.utils.testutils import TestCaseQt from silx.gui.colors import Colormap, preferredColormaps from silx.utils.testutils import ParametricTestCase from silx.gui.plot.PlotWindow import PlotWindow diff --git a/silx/gui/dialog/test/test_datafiledialog.py b/silx/gui/dialog/test/test_datafiledialog.py index 38fa03b..aff6bc4 100644 --- a/silx/gui/dialog/test/test_datafiledialog.py +++ b/silx/gui/dialog/test/test_datafiledialog.py @@ -26,7 +26,7 @@ __authors__ = ["V. Valls"] __license__ = "MIT" -__date__ = "03/07/2018" +__date__ = "05/10/2018" import unittest @@ -48,7 +48,7 @@ except ImportError: import silx.io.url from silx.gui import qt -from silx.gui.test import utils +from silx.gui.utils import testutils from ..DataFileDialog import DataFileDialog from silx.gui.hdf5 import Hdf5TreeModel @@ -134,7 +134,7 @@ class _UtilsMixin(object): path2_ = os.path.normcase(path2) if path1_ != path2_: # Use the unittest API to log and display error - self.assertEquals(path1, path2) + self.assertEqual(path1, path2) def assertNotSamePath(self, path1, path2): path1_ = os.path.normcase(path1) @@ -144,11 +144,11 @@ class _UtilsMixin(object): self.assertNotEquals(path1, path2) -class TestDataFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): +class TestDataFileDialogInteraction(testutils.TestCaseQt, _UtilsMixin): def tearDown(self): self._deleteDialog() - utils.TestCaseQt.tearDown(self) + testutils.TestCaseQt.tearDown(self) def testDisplayAndKeyEscape(self): dialog = self.createDialog() @@ -158,7 +158,7 @@ class TestDataFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): self.keyClick(dialog, qt.Qt.Key_Escape) self.assertFalse(dialog.isVisible()) - self.assertEquals(dialog.result(), qt.QDialog.Rejected) + self.assertEqual(dialog.result(), qt.QDialog.Rejected) def testDisplayAndClickCancel(self): dialog = self.createDialog() @@ -166,11 +166,11 @@ class TestDataFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): self.qWaitForWindowExposed(dialog) self.assertTrue(dialog.isVisible()) - button = utils.findChildren(dialog, qt.QPushButton, name="cancel")[0] + button = testutils.findChildren(dialog, qt.QPushButton, name="cancel")[0] self.mouseClick(button, qt.Qt.LeftButton) self.assertFalse(dialog.isVisible()) self.assertFalse(dialog.isVisible()) - self.assertEquals(dialog.result(), qt.QDialog.Rejected) + self.assertEqual(dialog.result(), qt.QDialog.Rejected) def testDisplayAndClickLockedOpen(self): dialog = self.createDialog() @@ -178,17 +178,17 @@ class TestDataFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): self.qWaitForWindowExposed(dialog) self.assertTrue(dialog.isVisible()) - button = utils.findChildren(dialog, qt.QPushButton, name="open")[0] + button = testutils.findChildren(dialog, qt.QPushButton, name="open")[0] self.mouseClick(button, qt.Qt.LeftButton) # open button locked, dialog is not closed self.assertTrue(dialog.isVisible()) - self.assertEquals(dialog.result(), qt.QDialog.Rejected) + self.assertEqual(dialog.result(), qt.QDialog.Rejected) def testSelectRoot_Activate(self): if fabio is None: self.skipTest("fabio is missing") dialog = self.createDialog() - browser = utils.findChildren(dialog, qt.QWidget, name="browser")[0] + browser = testutils.findChildren(dialog, qt.QWidget, name="browser")[0] dialog.show() self.qWaitForWindowExposed(dialog) self.assertTrue(dialog.isVisible()) @@ -202,19 +202,19 @@ class TestDataFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): browser.activated.emit(index) self.qWaitForPendingActions(dialog) - button = utils.findChildren(dialog, qt.QPushButton, name="open")[0] + button = testutils.findChildren(dialog, qt.QPushButton, name="open")[0] self.assertTrue(button.isEnabled()) self.mouseClick(button, qt.Qt.LeftButton) url = silx.io.url.DataUrl(dialog.selectedUrl()) self.assertTrue(url.data_path() is not None) self.assertFalse(dialog.isVisible()) - self.assertEquals(dialog.result(), qt.QDialog.Accepted) + self.assertEqual(dialog.result(), qt.QDialog.Accepted) def testSelectGroup_Activate(self): if fabio is None: self.skipTest("fabio is missing") dialog = self.createDialog() - browser = utils.findChildren(dialog, qt.QWidget, name="browser")[0] + browser = testutils.findChildren(dialog, qt.QWidget, name="browser")[0] dialog.show() self.qWaitForWindowExposed(dialog) self.assertTrue(dialog.isVisible()) @@ -234,19 +234,19 @@ class TestDataFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): browser.activated.emit(index) self.qWaitForPendingActions(dialog) - button = utils.findChildren(dialog, qt.QPushButton, name="open")[0] + button = testutils.findChildren(dialog, qt.QPushButton, name="open")[0] self.assertTrue(button.isEnabled()) self.mouseClick(button, qt.Qt.LeftButton) url = silx.io.url.DataUrl(dialog.selectedUrl()) self.assertEqual(url.data_path(), "/group") self.assertFalse(dialog.isVisible()) - self.assertEquals(dialog.result(), qt.QDialog.Accepted) + self.assertEqual(dialog.result(), qt.QDialog.Accepted) def testSelectDataset_Activate(self): if fabio is None: self.skipTest("fabio is missing") dialog = self.createDialog() - browser = utils.findChildren(dialog, qt.QWidget, name="browser")[0] + browser = testutils.findChildren(dialog, qt.QWidget, name="browser")[0] dialog.show() self.qWaitForWindowExposed(dialog) self.assertTrue(dialog.isVisible()) @@ -266,13 +266,13 @@ class TestDataFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): browser.activated.emit(index) self.qWaitForPendingActions(dialog) - button = utils.findChildren(dialog, qt.QPushButton, name="open")[0] + button = testutils.findChildren(dialog, qt.QPushButton, name="open")[0] self.assertTrue(button.isEnabled()) self.mouseClick(button, qt.Qt.LeftButton) url = silx.io.url.DataUrl(dialog.selectedUrl()) self.assertEqual(url.data_path(), "/scalar") self.assertFalse(dialog.isVisible()) - self.assertEquals(dialog.result(), qt.QDialog.Accepted) + self.assertEqual(dialog.result(), qt.QDialog.Accepted) def testClickOnBackToParentTool(self): if h5py is None: @@ -281,9 +281,9 @@ class TestDataFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): dialog.show() self.qWaitForWindowExposed(dialog) - url = utils.findChildren(dialog, qt.QLineEdit, name="url")[0] - action = utils.findChildren(dialog, qt.QAction, name="toParentAction")[0] - toParentButton = utils.getQToolButtonFromAction(action) + url = testutils.findChildren(dialog, qt.QLineEdit, name="url")[0] + action = testutils.findChildren(dialog, qt.QAction, name="toParentAction")[0] + toParentButton = testutils.getQToolButtonFromAction(action) filename = _tmpDirectory + "/data/data.h5" # init state @@ -313,9 +313,9 @@ class TestDataFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): dialog.show() self.qWaitForWindowExposed(dialog) - url = utils.findChildren(dialog, qt.QLineEdit, name="url")[0] - action = utils.findChildren(dialog, qt.QAction, name="toRootFileAction")[0] - button = utils.getQToolButtonFromAction(action) + url = testutils.findChildren(dialog, qt.QLineEdit, name="url")[0] + action = testutils.findChildren(dialog, qt.QAction, name="toRootFileAction")[0] + button = testutils.getQToolButtonFromAction(action) filename = _tmpDirectory + "/data.h5" # init state @@ -338,9 +338,9 @@ class TestDataFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): dialog.show() self.qWaitForWindowExposed(dialog) - url = utils.findChildren(dialog, qt.QLineEdit, name="url")[0] - action = utils.findChildren(dialog, qt.QAction, name="toDirectoryAction")[0] - button = utils.getQToolButtonFromAction(action) + url = testutils.findChildren(dialog, qt.QLineEdit, name="url")[0] + action = testutils.findChildren(dialog, qt.QAction, name="toDirectoryAction")[0] + button = testutils.getQToolButtonFromAction(action) filename = _tmpDirectory + "/data.h5" # init state @@ -367,9 +367,9 @@ class TestDataFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): dialog.show() self.qWaitForWindowExposed(dialog) - url = utils.findChildren(dialog, qt.QLineEdit, name="url")[0] - forwardAction = utils.findChildren(dialog, qt.QAction, name="forwardAction")[0] - backwardAction = utils.findChildren(dialog, qt.QAction, name="backwardAction")[0] + url = testutils.findChildren(dialog, qt.QLineEdit, name="url")[0] + forwardAction = testutils.findChildren(dialog, qt.QAction, name="forwardAction")[0] + backwardAction = testutils.findChildren(dialog, qt.QAction, name="backwardAction")[0] filename = _tmpDirectory + "/data.h5" dialog.setDirectory(_tmpDirectory) @@ -387,14 +387,14 @@ class TestDataFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): self.assertFalse(forwardAction.isEnabled()) self.assertTrue(backwardAction.isEnabled()) - button = utils.getQToolButtonFromAction(backwardAction) + button = testutils.getQToolButtonFromAction(backwardAction) self.mouseClick(button, qt.Qt.LeftButton) self.qWaitForPendingActions(dialog) self.assertTrue(forwardAction.isEnabled()) self.assertTrue(backwardAction.isEnabled()) self.assertSamePath(url.text(), path2) - button = utils.getQToolButtonFromAction(forwardAction) + button = testutils.getQToolButtonFromAction(forwardAction) self.mouseClick(button, qt.Qt.LeftButton) self.qWaitForPendingActions(dialog) self.assertFalse(forwardAction.isEnabled()) @@ -494,7 +494,7 @@ class TestDataFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): # init state dialog.selectUrl(_tmpDirectory) self.qWaitForPendingActions(dialog) - browser = utils.findChildren(dialog, qt.QWidget, name="browser")[0] + browser = testutils.findChildren(dialog, qt.QWidget, name="browser")[0] filename = _tmpDirectory + "/data.h5" path = silx.io.url.DataUrl(scheme="silx", file_path=filename, data_path="/").path() index = browser.rootIndex().model().index(filename) @@ -514,7 +514,7 @@ class TestDataFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): # init state dialog.selectUrl(_tmpDirectory) self.qWaitForPendingActions(dialog) - browser = utils.findChildren(dialog, qt.QWidget, name="browser")[0] + browser = testutils.findChildren(dialog, qt.QWidget, name="browser")[0] filename = _tmpDirectory + "/badformat.h5" index = browser.rootIndex().model().index(filename) browser.activated.emit(index) @@ -538,7 +538,7 @@ class TestDataFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): if fabio is None: self.skipTest("fabio is missing") dialog = self.createDialog() - browser = utils.findChildren(dialog, qt.QWidget, name="browser")[0] + browser = testutils.findChildren(dialog, qt.QWidget, name="browser")[0] dialog.show() self.qWaitForWindowExposed(dialog) dialog.selectUrl(_tmpDirectory) @@ -546,11 +546,11 @@ class TestDataFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): self.assertEqual(self._countSelectableItems(browser.model(), browser.rootIndex()), 4) -class TestDataFileDialog_FilterDataset(utils.TestCaseQt, _UtilsMixin): +class TestDataFileDialog_FilterDataset(testutils.TestCaseQt, _UtilsMixin): def tearDown(self): self._deleteDialog() - utils.TestCaseQt.tearDown(self) + testutils.TestCaseQt.tearDown(self) def _createDialog(self): dialog = DataFileDialog() @@ -561,7 +561,7 @@ class TestDataFileDialog_FilterDataset(utils.TestCaseQt, _UtilsMixin): if fabio is None: self.skipTest("fabio is missing") dialog = self.createDialog() - browser = utils.findChildren(dialog, qt.QWidget, name="browser")[0] + browser = testutils.findChildren(dialog, qt.QWidget, name="browser")[0] dialog.show() self.qWaitForWindowExposed(dialog) self.assertTrue(dialog.isVisible()) @@ -581,14 +581,14 @@ class TestDataFileDialog_FilterDataset(utils.TestCaseQt, _UtilsMixin): browser.activated.emit(index) self.qWaitForPendingActions(dialog) - button = utils.findChildren(dialog, qt.QPushButton, name="open")[0] + button = testutils.findChildren(dialog, qt.QPushButton, name="open")[0] self.assertFalse(button.isEnabled()) def testSelectDataset_Activate(self): if fabio is None: self.skipTest("fabio is missing") dialog = self.createDialog() - browser = utils.findChildren(dialog, qt.QWidget, name="browser")[0] + browser = testutils.findChildren(dialog, qt.QWidget, name="browser")[0] dialog.show() self.qWaitForWindowExposed(dialog) self.assertTrue(dialog.isVisible()) @@ -608,23 +608,23 @@ class TestDataFileDialog_FilterDataset(utils.TestCaseQt, _UtilsMixin): browser.activated.emit(index) self.qWaitForPendingActions(dialog) - button = utils.findChildren(dialog, qt.QPushButton, name="open")[0] + button = testutils.findChildren(dialog, qt.QPushButton, name="open")[0] self.assertTrue(button.isEnabled()) self.mouseClick(button, qt.Qt.LeftButton) url = silx.io.url.DataUrl(dialog.selectedUrl()) self.assertEqual(url.data_path(), "/scalar") self.assertFalse(dialog.isVisible()) - self.assertEquals(dialog.result(), qt.QDialog.Accepted) + self.assertEqual(dialog.result(), qt.QDialog.Accepted) data = dialog.selectedData() self.assertEqual(data, 10) -class TestDataFileDialog_FilterGroup(utils.TestCaseQt, _UtilsMixin): +class TestDataFileDialog_FilterGroup(testutils.TestCaseQt, _UtilsMixin): def tearDown(self): self._deleteDialog() - utils.TestCaseQt.tearDown(self) + testutils.TestCaseQt.tearDown(self) def _createDialog(self): dialog = DataFileDialog() @@ -635,7 +635,7 @@ class TestDataFileDialog_FilterGroup(utils.TestCaseQt, _UtilsMixin): if fabio is None: self.skipTest("fabio is missing") dialog = self.createDialog() - browser = utils.findChildren(dialog, qt.QWidget, name="browser")[0] + browser = testutils.findChildren(dialog, qt.QWidget, name="browser")[0] dialog.show() self.qWaitForWindowExposed(dialog) self.assertTrue(dialog.isVisible()) @@ -655,13 +655,13 @@ class TestDataFileDialog_FilterGroup(utils.TestCaseQt, _UtilsMixin): browser.activated.emit(index) self.qWaitForPendingActions(dialog) - button = utils.findChildren(dialog, qt.QPushButton, name="open")[0] + button = testutils.findChildren(dialog, qt.QPushButton, name="open")[0] self.assertTrue(button.isEnabled()) self.mouseClick(button, qt.Qt.LeftButton) url = silx.io.url.DataUrl(dialog.selectedUrl()) self.assertEqual(url.data_path(), "/group") self.assertFalse(dialog.isVisible()) - self.assertEquals(dialog.result(), qt.QDialog.Accepted) + self.assertEqual(dialog.result(), qt.QDialog.Accepted) self.assertRaises(Exception, dialog.selectedData) @@ -669,7 +669,7 @@ class TestDataFileDialog_FilterGroup(utils.TestCaseQt, _UtilsMixin): if fabio is None: self.skipTest("fabio is missing") dialog = self.createDialog() - browser = utils.findChildren(dialog, qt.QWidget, name="browser")[0] + browser = testutils.findChildren(dialog, qt.QWidget, name="browser")[0] dialog.show() self.qWaitForWindowExposed(dialog) self.assertTrue(dialog.isVisible()) @@ -689,15 +689,15 @@ class TestDataFileDialog_FilterGroup(utils.TestCaseQt, _UtilsMixin): browser.activated.emit(index) self.qWaitForPendingActions(dialog) - button = utils.findChildren(dialog, qt.QPushButton, name="open")[0] + button = testutils.findChildren(dialog, qt.QPushButton, name="open")[0] self.assertFalse(button.isEnabled()) -class TestDataFileDialog_FilterNXdata(utils.TestCaseQt, _UtilsMixin): +class TestDataFileDialog_FilterNXdata(testutils.TestCaseQt, _UtilsMixin): def tearDown(self): self._deleteDialog() - utils.TestCaseQt.tearDown(self) + testutils.TestCaseQt.tearDown(self) def _createDialog(self): def customFilter(obj): @@ -714,7 +714,7 @@ class TestDataFileDialog_FilterNXdata(utils.TestCaseQt, _UtilsMixin): if fabio is None: self.skipTest("fabio is missing") dialog = self.createDialog() - browser = utils.findChildren(dialog, qt.QWidget, name="browser")[0] + browser = testutils.findChildren(dialog, qt.QWidget, name="browser")[0] dialog.show() self.qWaitForWindowExposed(dialog) self.assertTrue(dialog.isVisible()) @@ -734,7 +734,7 @@ class TestDataFileDialog_FilterNXdata(utils.TestCaseQt, _UtilsMixin): browser.activated.emit(index) self.qWaitForPendingActions(dialog) - button = utils.findChildren(dialog, qt.QPushButton, name="open")[0] + button = testutils.findChildren(dialog, qt.QPushButton, name="open")[0] self.assertFalse(button.isEnabled()) self.assertRaises(Exception, dialog.selectedData) @@ -743,7 +743,7 @@ class TestDataFileDialog_FilterNXdata(utils.TestCaseQt, _UtilsMixin): if fabio is None: self.skipTest("fabio is missing") dialog = self.createDialog() - browser = utils.findChildren(dialog, qt.QWidget, name="browser")[0] + browser = testutils.findChildren(dialog, qt.QWidget, name="browser")[0] dialog.show() self.qWaitForWindowExposed(dialog) self.assertTrue(dialog.isVisible()) @@ -763,20 +763,20 @@ class TestDataFileDialog_FilterNXdata(utils.TestCaseQt, _UtilsMixin): browser.activated.emit(index) self.qWaitForPendingActions(dialog) - button = utils.findChildren(dialog, qt.QPushButton, name="open")[0] + button = testutils.findChildren(dialog, qt.QPushButton, name="open")[0] self.assertTrue(button.isEnabled()) self.mouseClick(button, qt.Qt.LeftButton) url = silx.io.url.DataUrl(dialog.selectedUrl()) self.assertEqual(url.data_path(), "/nxdata") self.assertFalse(dialog.isVisible()) - self.assertEquals(dialog.result(), qt.QDialog.Accepted) + self.assertEqual(dialog.result(), qt.QDialog.Accepted) -class TestDataFileDialogApi(utils.TestCaseQt, _UtilsMixin): +class TestDataFileDialogApi(testutils.TestCaseQt, _UtilsMixin): def tearDown(self): self._deleteDialog() - utils.TestCaseQt.tearDown(self) + testutils.TestCaseQt.tearDown(self) def _createDialog(self): dialog = DataFileDialog() @@ -949,7 +949,7 @@ class TestDataFileDialogApi(utils.TestCaseQt, _UtilsMixin): dialog = self.createDialog() self.qWaitForPendingActions(dialog) - browser = utils.findChildren(dialog, qt.QWidget, name="browser")[0] + browser = testutils.findChildren(dialog, qt.QWidget, name="browser")[0] filename = _tmpDirectory + "/data.h5" url = silx.io.url.DataUrl(scheme="silx", file_path=filename, data_path="/group/foobar") diff --git a/silx/gui/dialog/test/test_imagefiledialog.py b/silx/gui/dialog/test/test_imagefiledialog.py index 8fef3c5..66469f3 100644 --- a/silx/gui/dialog/test/test_imagefiledialog.py +++ b/silx/gui/dialog/test/test_imagefiledialog.py @@ -26,7 +26,7 @@ __authors__ = ["V. Valls"] __license__ = "MIT" -__date__ = "03/07/2018" +__date__ = "05/10/2018" import unittest @@ -48,7 +48,7 @@ except ImportError: import silx.io.url from silx.gui import qt -from silx.gui.test import utils +from silx.gui.utils import testutils from ..ImageFileDialog import ImageFileDialog from silx.gui.colors import Colormap from silx.gui.hdf5 import Hdf5TreeModel @@ -141,7 +141,7 @@ class _UtilsMixin(object): path2_ = os.path.normcase(path2) if path1_ != path2_: # Use the unittest API to log and display error - self.assertEquals(path1, path2) + self.assertEqual(path1, path2) def assertNotSamePath(self, path1, path2): path1_ = os.path.normcase(path1) @@ -151,11 +151,11 @@ class _UtilsMixin(object): self.assertNotEquals(path1, path2) -class TestImageFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): +class TestImageFileDialogInteraction(testutils.TestCaseQt, _UtilsMixin): def tearDown(self): self._deleteDialog() - utils.TestCaseQt.tearDown(self) + testutils.TestCaseQt.tearDown(self) def testDisplayAndKeyEscape(self): dialog = self.createDialog() @@ -165,7 +165,7 @@ class TestImageFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): self.keyClick(dialog, qt.Qt.Key_Escape) self.assertFalse(dialog.isVisible()) - self.assertEquals(dialog.result(), qt.QDialog.Rejected) + self.assertEqual(dialog.result(), qt.QDialog.Rejected) def testDisplayAndClickCancel(self): dialog = self.createDialog() @@ -173,11 +173,11 @@ class TestImageFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): self.qWaitForWindowExposed(dialog) self.assertTrue(dialog.isVisible()) - button = utils.findChildren(dialog, qt.QPushButton, name="cancel")[0] + button = testutils.findChildren(dialog, qt.QPushButton, name="cancel")[0] self.mouseClick(button, qt.Qt.LeftButton) self.assertFalse(dialog.isVisible()) self.assertFalse(dialog.isVisible()) - self.assertEquals(dialog.result(), qt.QDialog.Rejected) + self.assertEqual(dialog.result(), qt.QDialog.Rejected) def testDisplayAndClickLockedOpen(self): dialog = self.createDialog() @@ -185,11 +185,11 @@ class TestImageFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): self.qWaitForWindowExposed(dialog) self.assertTrue(dialog.isVisible()) - button = utils.findChildren(dialog, qt.QPushButton, name="open")[0] + button = testutils.findChildren(dialog, qt.QPushButton, name="open")[0] self.mouseClick(button, qt.Qt.LeftButton) # open button locked, dialog is not closed self.assertTrue(dialog.isVisible()) - self.assertEquals(dialog.result(), qt.QDialog.Rejected) + self.assertEqual(dialog.result(), qt.QDialog.Rejected) def testDisplayAndClickOpen(self): if fabio is None: @@ -202,20 +202,20 @@ class TestImageFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): dialog.selectFile(filename) self.qWaitForPendingActions(dialog) - button = utils.findChildren(dialog, qt.QPushButton, name="open")[0] + button = testutils.findChildren(dialog, qt.QPushButton, name="open")[0] self.assertTrue(button.isEnabled()) self.mouseClick(button, qt.Qt.LeftButton) self.assertFalse(dialog.isVisible()) - self.assertEquals(dialog.result(), qt.QDialog.Accepted) + self.assertEqual(dialog.result(), qt.QDialog.Accepted) def testClickOnShortcut(self): dialog = self.createDialog() dialog.show() self.qWaitForWindowExposed(dialog) - sidebar = utils.findChildren(dialog, qt.QListView, name="sidebar")[0] - url = utils.findChildren(dialog, qt.QLineEdit, name="url")[0] - browser = utils.findChildren(dialog, qt.QWidget, name="browser")[0] + sidebar = testutils.findChildren(dialog, qt.QListView, name="sidebar")[0] + url = testutils.findChildren(dialog, qt.QLineEdit, name="url")[0] + browser = testutils.findChildren(dialog, qt.QWidget, name="browser")[0] dialog.setDirectory(_tmpDirectory) self.qWaitForPendingActions(dialog) @@ -248,13 +248,13 @@ class TestImageFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): dialog.show() self.qWaitForWindowExposed(dialog) - action = utils.findChildren(dialog, qt.QAction, name="detailModeAction")[0] - detailModeButton = utils.getQToolButtonFromAction(action) + action = testutils.findChildren(dialog, qt.QAction, name="detailModeAction")[0] + detailModeButton = testutils.getQToolButtonFromAction(action) self.mouseClick(detailModeButton, qt.Qt.LeftButton) self.assertEqual(dialog.viewMode(), qt.QFileDialog.Detail) - action = utils.findChildren(dialog, qt.QAction, name="listModeAction")[0] - listModeButton = utils.getQToolButtonFromAction(action) + action = testutils.findChildren(dialog, qt.QAction, name="listModeAction")[0] + listModeButton = testutils.getQToolButtonFromAction(action) self.mouseClick(listModeButton, qt.Qt.LeftButton) self.assertEqual(dialog.viewMode(), qt.QFileDialog.List) @@ -265,9 +265,9 @@ class TestImageFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): dialog.show() self.qWaitForWindowExposed(dialog) - url = utils.findChildren(dialog, qt.QLineEdit, name="url")[0] - action = utils.findChildren(dialog, qt.QAction, name="toParentAction")[0] - toParentButton = utils.getQToolButtonFromAction(action) + url = testutils.findChildren(dialog, qt.QLineEdit, name="url")[0] + action = testutils.findChildren(dialog, qt.QAction, name="toParentAction")[0] + toParentButton = testutils.getQToolButtonFromAction(action) filename = _tmpDirectory + "/data/data.h5" # init state @@ -275,23 +275,19 @@ class TestImageFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): dialog.selectUrl(path) self.qWaitForPendingActions(dialog) path = silx.io.url.DataUrl(scheme="silx", file_path=filename, data_path="/group/image").path() - print(url.text()) self.assertSamePath(url.text(), path) # test self.mouseClick(toParentButton, qt.Qt.LeftButton) self.qWaitForPendingActions(dialog) path = silx.io.url.DataUrl(scheme="silx", file_path=filename, data_path="/").path() - print(url.text()) self.assertSamePath(url.text(), path) self.mouseClick(toParentButton, qt.Qt.LeftButton) self.qWaitForPendingActions(dialog) - print(url.text()) self.assertSamePath(url.text(), _tmpDirectory + "/data") self.mouseClick(toParentButton, qt.Qt.LeftButton) self.qWaitForPendingActions(dialog) - print(url.text()) self.assertSamePath(url.text(), _tmpDirectory) def testClickOnBackToRootTool(self): @@ -301,9 +297,9 @@ class TestImageFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): dialog.show() self.qWaitForWindowExposed(dialog) - url = utils.findChildren(dialog, qt.QLineEdit, name="url")[0] - action = utils.findChildren(dialog, qt.QAction, name="toRootFileAction")[0] - button = utils.getQToolButtonFromAction(action) + url = testutils.findChildren(dialog, qt.QLineEdit, name="url")[0] + action = testutils.findChildren(dialog, qt.QAction, name="toRootFileAction")[0] + button = testutils.getQToolButtonFromAction(action) filename = _tmpDirectory + "/data.h5" # init state @@ -326,9 +322,9 @@ class TestImageFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): dialog.show() self.qWaitForWindowExposed(dialog) - url = utils.findChildren(dialog, qt.QLineEdit, name="url")[0] - action = utils.findChildren(dialog, qt.QAction, name="toDirectoryAction")[0] - button = utils.getQToolButtonFromAction(action) + url = testutils.findChildren(dialog, qt.QLineEdit, name="url")[0] + action = testutils.findChildren(dialog, qt.QAction, name="toDirectoryAction")[0] + button = testutils.getQToolButtonFromAction(action) filename = _tmpDirectory + "/data.h5" # init state @@ -355,9 +351,9 @@ class TestImageFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): dialog.show() self.qWaitForWindowExposed(dialog) - url = utils.findChildren(dialog, qt.QLineEdit, name="url")[0] - forwardAction = utils.findChildren(dialog, qt.QAction, name="forwardAction")[0] - backwardAction = utils.findChildren(dialog, qt.QAction, name="backwardAction")[0] + url = testutils.findChildren(dialog, qt.QLineEdit, name="url")[0] + forwardAction = testutils.findChildren(dialog, qt.QAction, name="forwardAction")[0] + backwardAction = testutils.findChildren(dialog, qt.QAction, name="backwardAction")[0] filename = _tmpDirectory + "/data.h5" dialog.setDirectory(_tmpDirectory) @@ -375,14 +371,14 @@ class TestImageFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): self.assertFalse(forwardAction.isEnabled()) self.assertTrue(backwardAction.isEnabled()) - button = utils.getQToolButtonFromAction(backwardAction) + button = testutils.getQToolButtonFromAction(backwardAction) self.mouseClick(button, qt.Qt.LeftButton) self.qWaitForPendingActions(dialog) self.assertTrue(forwardAction.isEnabled()) self.assertTrue(backwardAction.isEnabled()) self.assertSamePath(url.text(), path2) - button = utils.getQToolButtonFromAction(forwardAction) + button = testutils.getQToolButtonFromAction(forwardAction) self.mouseClick(button, qt.Qt.LeftButton) self.qWaitForPendingActions(dialog) self.assertFalse(forwardAction.isEnabled()) @@ -415,7 +411,7 @@ class TestImageFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): # init state dialog.selectUrl(_tmpDirectory) self.qWaitForPendingActions(dialog) - browser = utils.findChildren(dialog, qt.QWidget, name="browser")[0] + browser = testutils.findChildren(dialog, qt.QWidget, name="browser")[0] filename = _tmpDirectory + "/singleimage.edf" path = silx.io.url.DataUrl(scheme="fabio", file_path=filename).path() index = browser.rootIndex().model().index(filename) @@ -489,7 +485,7 @@ class TestImageFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): # init state dialog.selectUrl(_tmpDirectory) self.qWaitForPendingActions(dialog) - browser = utils.findChildren(dialog, qt.QWidget, name="browser")[0] + browser = testutils.findChildren(dialog, qt.QWidget, name="browser")[0] filename = _tmpDirectory + "/data.h5" path = silx.io.url.DataUrl(scheme="silx", file_path=filename, data_path="/").path() index = browser.rootIndex().model().index(filename) @@ -526,7 +522,7 @@ class TestImageFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): # init state dialog.selectUrl(_tmpDirectory) self.qWaitForPendingActions(dialog) - browser = utils.findChildren(dialog, qt.QWidget, name="browser")[0] + browser = testutils.findChildren(dialog, qt.QWidget, name="browser")[0] filename = _tmpDirectory + "/badformat.edf" index = browser.rootIndex().model().index(filename) browser.activated.emit(index) @@ -550,8 +546,8 @@ class TestImageFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): if fabio is None: self.skipTest("fabio is missing") dialog = self.createDialog() - browser = utils.findChildren(dialog, qt.QWidget, name="browser")[0] - filters = utils.findChildren(dialog, qt.QWidget, name="fileTypeCombo")[0] + browser = testutils.findChildren(dialog, qt.QWidget, name="browser")[0] + filters = testutils.findChildren(dialog, qt.QWidget, name="fileTypeCombo")[0] dialog.show() self.qWaitForWindowExposed(dialog) dialog.selectUrl(_tmpDirectory) @@ -573,11 +569,11 @@ class TestImageFileDialogInteraction(utils.TestCaseQt, _UtilsMixin): self.assertEqual(self._countSelectableItems(browser.model(), browser.rootIndex()), 2) -class TestImageFileDialogApi(utils.TestCaseQt, _UtilsMixin): +class TestImageFileDialogApi(testutils.TestCaseQt, _UtilsMixin): def tearDown(self): self._deleteDialog() - utils.TestCaseQt.tearDown(self) + testutils.TestCaseQt.tearDown(self) def testSaveRestoreState(self): dialog = self.createDialog() @@ -782,7 +778,7 @@ class TestImageFileDialogApi(utils.TestCaseQt, _UtilsMixin): dialog = self.createDialog() self.qWaitForPendingActions(dialog) - browser = utils.findChildren(dialog, qt.QWidget, name="browser")[0] + browser = testutils.findChildren(dialog, qt.QWidget, name="browser")[0] filename = _tmpDirectory + "/data.h5" url = silx.io.url.DataUrl(scheme="silx", file_path=filename, data_path="/group/foobar") |