summaryrefslogtreecommitdiff
path: root/silx/gui/dialog/test/test_imagefiledialog.py
diff options
context:
space:
mode:
Diffstat (limited to 'silx/gui/dialog/test/test_imagefiledialog.py')
-rw-r--r--silx/gui/dialog/test/test_imagefiledialog.py117
1 files changed, 35 insertions, 82 deletions
diff --git a/silx/gui/dialog/test/test_imagefiledialog.py b/silx/gui/dialog/test/test_imagefiledialog.py
index 66469f3..068dcb9 100644
--- a/silx/gui/dialog/test/test_imagefiledialog.py
+++ b/silx/gui/dialog/test/test_imagefiledialog.py
@@ -36,16 +36,8 @@ import shutil
import os
import io
import weakref
-
-try:
- import fabio
-except ImportError:
- fabio = None
-try:
- import h5py
-except ImportError:
- h5py = None
-
+import fabio
+import h5py
import silx.io.url
from silx.gui import qt
from silx.gui.utils import testutils
@@ -63,42 +55,39 @@ def setUpModule():
data = numpy.arange(100 * 100)
data.shape = 100, 100
- if fabio is not None:
- filename = _tmpDirectory + "/singleimage.edf"
- image = fabio.edfimage.EdfImage(data=data)
- image.write(filename)
-
- filename = _tmpDirectory + "/multiframe.edf"
- image = fabio.edfimage.EdfImage(data=data)
- image.appendFrame(data=data + 1)
- image.appendFrame(data=data + 2)
- image.write(filename)
-
- filename = _tmpDirectory + "/singleimage.msk"
- image = fabio.fit2dmaskimage.Fit2dMaskImage(data=data % 2 == 1)
- image.write(filename)
-
- if h5py is not None:
- filename = _tmpDirectory + "/data.h5"
- f = h5py.File(filename, "w")
- f["scalar"] = 10
- f["image"] = data
- f["cube"] = [data, data + 1, data + 2]
- f["complex_image"] = data * 1j
- f["group/image"] = data
- f.close()
-
- if h5py is not None:
- directory = os.path.join(_tmpDirectory, "data")
- os.mkdir(directory)
- filename = os.path.join(directory, "data.h5")
- f = h5py.File(filename, "w")
- f["scalar"] = 10
- f["image"] = data
- f["cube"] = [data, data + 1, data + 2]
- f["complex_image"] = data * 1j
- f["group/image"] = data
- f.close()
+ filename = _tmpDirectory + "/singleimage.edf"
+ image = fabio.edfimage.EdfImage(data=data)
+ image.write(filename)
+
+ filename = _tmpDirectory + "/multiframe.edf"
+ image = fabio.edfimage.EdfImage(data=data)
+ image.appendFrame(data=data + 1)
+ image.appendFrame(data=data + 2)
+ image.write(filename)
+
+ filename = _tmpDirectory + "/singleimage.msk"
+ image = fabio.fit2dmaskimage.Fit2dMaskImage(data=data % 2 == 1)
+ image.write(filename)
+
+ filename = _tmpDirectory + "/data.h5"
+ f = h5py.File(filename, "w")
+ f["scalar"] = 10
+ f["image"] = data
+ f["cube"] = [data, data + 1, data + 2]
+ f["complex_image"] = data * 1j
+ f["group/image"] = data
+ f.close()
+
+ directory = os.path.join(_tmpDirectory, "data")
+ os.mkdir(directory)
+ filename = os.path.join(directory, "data.h5")
+ f = h5py.File(filename, "w")
+ f["scalar"] = 10
+ f["image"] = data
+ f["cube"] = [data, data + 1, data + 2]
+ f["complex_image"] = data * 1j
+ f["group/image"] = data
+ f.close()
filename = _tmpDirectory + "/badformat.edf"
with io.open(filename, "wb") as f:
@@ -192,8 +181,6 @@ class TestImageFileDialogInteraction(testutils.TestCaseQt, _UtilsMixin):
self.assertEqual(dialog.result(), qt.QDialog.Rejected)
def testDisplayAndClickOpen(self):
- if fabio is None:
- self.skipTest("fabio is missing")
dialog = self.createDialog()
dialog.show()
self.qWaitForWindowExposed(dialog)
@@ -259,8 +246,6 @@ class TestImageFileDialogInteraction(testutils.TestCaseQt, _UtilsMixin):
self.assertEqual(dialog.viewMode(), qt.QFileDialog.List)
def testClickOnBackToParentTool(self):
- if h5py is None:
- self.skipTest("h5py is missing")
dialog = self.createDialog()
dialog.show()
self.qWaitForWindowExposed(dialog)
@@ -291,8 +276,6 @@ class TestImageFileDialogInteraction(testutils.TestCaseQt, _UtilsMixin):
self.assertSamePath(url.text(), _tmpDirectory)
def testClickOnBackToRootTool(self):
- if h5py is None:
- self.skipTest("h5py is missing")
dialog = self.createDialog()
dialog.show()
self.qWaitForWindowExposed(dialog)
@@ -316,8 +299,6 @@ class TestImageFileDialogInteraction(testutils.TestCaseQt, _UtilsMixin):
# self.assertFalse(button.isEnabled())
def testClickOnBackToDirectoryTool(self):
- if h5py is None:
- self.skipTest("h5py is missing")
dialog = self.createDialog()
dialog.show()
self.qWaitForWindowExposed(dialog)
@@ -345,8 +326,6 @@ class TestImageFileDialogInteraction(testutils.TestCaseQt, _UtilsMixin):
self.allowedLeakingWidgets = 1
def testClickOnHistoryTools(self):
- if h5py is None:
- self.skipTest("h5py is missing")
dialog = self.createDialog()
dialog.show()
self.qWaitForWindowExposed(dialog)
@@ -386,8 +365,6 @@ class TestImageFileDialogInteraction(testutils.TestCaseQt, _UtilsMixin):
self.assertSamePath(url.text(), path3)
def testSelectImageFromEdf(self):
- if fabio is None:
- self.skipTest("fabio is missing")
dialog = self.createDialog()
dialog.show()
self.qWaitForWindowExposed(dialog)
@@ -402,8 +379,6 @@ class TestImageFileDialogInteraction(testutils.TestCaseQt, _UtilsMixin):
self.assertSamePath(dialog.selectedUrl(), path)
def testSelectImageFromEdf_Activate(self):
- if fabio is None:
- self.skipTest("fabio is missing")
dialog = self.createDialog()
dialog.show()
self.qWaitForWindowExposed(dialog)
@@ -426,8 +401,6 @@ class TestImageFileDialogInteraction(testutils.TestCaseQt, _UtilsMixin):
self.assertSamePath(dialog.selectedUrl(), path)
def testSelectFrameFromEdf(self):
- if fabio is None:
- self.skipTest("fabio is missing")
dialog = self.createDialog()
dialog.show()
self.qWaitForWindowExposed(dialog)
@@ -444,8 +417,6 @@ class TestImageFileDialogInteraction(testutils.TestCaseQt, _UtilsMixin):
self.assertSamePath(dialog.selectedUrl(), path)
def testSelectImageFromMsk(self):
- if fabio is None:
- self.skipTest("fabio is missing")
dialog = self.createDialog()
dialog.show()
self.qWaitForWindowExposed(dialog)
@@ -460,8 +431,6 @@ class TestImageFileDialogInteraction(testutils.TestCaseQt, _UtilsMixin):
self.assertSamePath(dialog.selectedUrl(), path)
def testSelectImageFromH5(self):
- if h5py is None:
- self.skipTest("h5py is missing")
dialog = self.createDialog()
dialog.show()
self.qWaitForWindowExposed(dialog)
@@ -476,8 +445,6 @@ class TestImageFileDialogInteraction(testutils.TestCaseQt, _UtilsMixin):
self.assertSamePath(dialog.selectedUrl(), path)
def testSelectH5_Activate(self):
- if h5py is None:
- self.skipTest("h5py is missing")
dialog = self.createDialog()
dialog.show()
self.qWaitForWindowExposed(dialog)
@@ -498,8 +465,6 @@ class TestImageFileDialogInteraction(testutils.TestCaseQt, _UtilsMixin):
self.assertSamePath(dialog.selectedUrl(), path)
def testSelectFrameFromH5(self):
- if h5py is None:
- self.skipTest("h5py is missing")
dialog = self.createDialog()
dialog.show()
self.qWaitForWindowExposed(dialog)
@@ -541,10 +506,6 @@ class TestImageFileDialogInteraction(testutils.TestCaseQt, _UtilsMixin):
return selectable
def testFilterExtensions(self):
- if h5py is None:
- self.skipTest("h5py is missing")
- if fabio is None:
- self.skipTest("fabio is missing")
dialog = self.createDialog()
browser = testutils.findChildren(dialog, qt.QWidget, name="browser")[0]
filters = testutils.findChildren(dialog, qt.QWidget, name="fileTypeCombo")[0]
@@ -745,16 +706,12 @@ class TestImageFileDialogApi(testutils.TestCaseQt, _UtilsMixin):
self.assertSamePath(dialog.directory(), _tmpDirectory)
def testBadDataType(self):
- if h5py is None:
- self.skipTest("h5py is missing")
dialog = self.createDialog()
dialog.selectUrl(_tmpDirectory + "/data.h5::/complex_image")
self.qWaitForPendingActions(dialog)
self.assertIsNone(dialog._selectedData())
def testBadDataShape(self):
- if h5py is None:
- self.skipTest("h5py is missing")
dialog = self.createDialog()
dialog.selectUrl(_tmpDirectory + "/data.h5::/unknown")
self.qWaitForPendingActions(dialog)
@@ -773,8 +730,6 @@ class TestImageFileDialogApi(testutils.TestCaseQt, _UtilsMixin):
self.assertIsNone(dialog._selectedData())
def testBadSubpath(self):
- if h5py is None:
- self.skipTest("h5py is missing")
dialog = self.createDialog()
self.qWaitForPendingActions(dialog)
@@ -794,8 +749,6 @@ class TestImageFileDialogApi(testutils.TestCaseQt, _UtilsMixin):
self.assertEqual(url.data_path(), "/group")
def testBadSlicingPath(self):
- if h5py is None:
- self.skipTest("h5py is missing")
dialog = self.createDialog()
self.qWaitForPendingActions(dialog)
dialog.selectUrl(_tmpDirectory + "/data.h5::/cube[a;45,-90]")