summaryrefslogtreecommitdiff
path: root/silx/gui/test/test_icons.py
diff options
context:
space:
mode:
authorPicca Frédéric-Emmanuel <picca@debian.org>2017-10-07 07:59:01 +0200
committerPicca Frédéric-Emmanuel <picca@debian.org>2017-10-07 07:59:01 +0200
commitbfa4dba15485b4192f8bbe13345e9658c97ecf76 (patch)
treefb9c6e5860881fbde902f7cbdbd41dc4a3a9fb5d /silx/gui/test/test_icons.py
parentf7bdc2acff3c13a6d632c28c4569690ab106eed7 (diff)
New upstream version 0.6.0+dfsg
Diffstat (limited to 'silx/gui/test/test_icons.py')
-rw-r--r--silx/gui/test/test_icons.py56
1 files changed, 49 insertions, 7 deletions
diff --git a/silx/gui/test/test_icons.py b/silx/gui/test/test_icons.py
index f363c43..d747761 100644
--- a/silx/gui/test/test_icons.py
+++ b/silx/gui/test/test_icons.py
@@ -26,13 +26,17 @@
__authors__ = ["V. Valls"]
__license__ = "MIT"
-__date__ = "26/04/2017"
+__date__ = "06/09/2017"
import gc
import unittest
import weakref
+import tempfile
+import shutil
+import os
+import silx.resources
from silx.gui import qt
from silx.gui.test.utils import TestCaseQt
from silx.gui import icons
@@ -41,14 +45,49 @@ from silx.gui import icons
class TestIcons(TestCaseQt):
"""Test to check that icons module."""
+ @classmethod
+ def setUpClass(cls):
+ super(TestIcons, cls).setUpClass()
+
+ cls.tmpDirectory = tempfile.mkdtemp(prefix="resource_")
+ os.mkdir(os.path.join(cls.tmpDirectory, "gui"))
+ destination = os.path.join(cls.tmpDirectory, "gui", "icons")
+ os.mkdir(destination)
+ shutil.copy(silx.resources.resource_filename("gui/icons/zoom-in.png"), destination)
+ shutil.copy(silx.resources.resource_filename("gui/icons/zoom-out.svg"), destination)
+
+ @classmethod
+ def tearDownClass(cls):
+ super(TestIcons, cls).tearDownClass()
+ shutil.rmtree(cls.tmpDirectory)
+
+ def setUp(self):
+ # Store the original configuration
+ self._oldResources = dict(silx.resources._RESOURCE_DIRECTORIES)
+ silx.resources.register_resource_directory("test", "foo.bar", forced_path=self.tmpDirectory)
+ unittest.TestCase.setUp(self)
+
+ def tearDown(self):
+ unittest.TestCase.tearDown(self)
+ # Restiture the original configuration
+ silx.resources._RESOURCE_DIRECTORIES = self._oldResources
+
+ def testIcon(self):
+ icon = icons.getQIcon("silx:gui/icons/zoom-out")
+ self.assertIsNotNone(icon)
+
+ def testPrefix(self):
+ icon = icons.getQIcon("silx:gui/icons/zoom-out")
+ self.assertIsNotNone(icon)
+
def testSvgIcon(self):
if "svg" not in qt.supportedImageFormats():
self.skipTest("SVG not supported")
- icon = icons.getQIcon("test-svg")
+ icon = icons.getQIcon("test:gui/icons/zoom-out")
self.assertIsNotNone(icon)
def testPngIcon(self):
- icon = icons.getQIcon("test-png")
+ icon = icons.getQIcon("test:gui/icons/zoom-in")
self.assertIsNotNone(icon)
def testUnexistingIcon(self):
@@ -99,16 +138,19 @@ class TestAnimatedIcons(TestCaseQt):
icon = icons.MultiImageAnimatedIcon("process-working")
self.assertIsNotNone(icon)
+ def testPrefixedResourceExists(self):
+ icon = icons.MultiImageAnimatedIcon("silx:gui/icons/process-working")
+ self.assertIsNotNone(icon)
+
def testMultiImageIconNotExists(self):
self.assertRaises(ValueError, icons.MultiImageAnimatedIcon, "not-exists")
def suite():
+ loadTests = unittest.defaultTestLoader.loadTestsFromTestCase
test_suite = unittest.TestSuite()
- test_suite.addTest(
- unittest.defaultTestLoader.loadTestsFromTestCase(TestIcons))
- test_suite.addTest(
- unittest.defaultTestLoader.loadTestsFromTestCase(TestAnimatedIcons))
+ test_suite.addTest(loadTests(TestIcons))
+ test_suite.addTest(loadTests(TestAnimatedIcons))
return test_suite