summaryrefslogtreecommitdiff
path: root/silx/gui/plot/test/testPlotWidget.py
diff options
context:
space:
mode:
Diffstat (limited to 'silx/gui/plot/test/testPlotWidget.py')
-rw-r--r--silx/gui/plot/test/testPlotWidget.py71
1 files changed, 40 insertions, 31 deletions
diff --git a/silx/gui/plot/test/testPlotWidget.py b/silx/gui/plot/test/testPlotWidget.py
index 72617e5..dac6580 100644
--- a/silx/gui/plot/test/testPlotWidget.py
+++ b/silx/gui/plot/test/testPlotWidget.py
@@ -1,7 +1,7 @@
# coding: utf-8
# /*##########################################################################
#
-# Copyright (c) 2016-2017 European Synchrotron Radiation Facility
+# Copyright (c) 2016-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
@@ -26,22 +26,24 @@
__authors__ = ["T. Vincent"]
__license__ = "MIT"
-__date__ = "26/01/2018"
+__date__ = "24/04/2018"
import unittest
import logging
import numpy
-from silx.utils.testutils import ParametricTestCase
+from silx.utils.testutils import ParametricTestCase, parameterize
from silx.gui.test.utils import SignalListener
from silx.gui.test.utils import TestCaseQt
from silx.utils import testutils
from silx.utils import deprecation
+from silx.test.utils import test_options
+
from silx.gui import qt
from silx.gui.plot import PlotWidget
-from silx.gui.plot.Colormap import Colormap
+from silx.gui.colors import Colormap
from .utils import PlotWidgetTestCase
@@ -188,7 +190,7 @@ class TestPlotImage(PlotWidgetTestCase, ParametricTestCase):
self.plot.addImage(rgb, legend="rgb",
origin=(0, 0), scale=(10, 10),
- replace=False, resetzoom=False)
+ resetzoom=False)
rgba = numpy.array(
(((0, 0, 0, .5), (.5, 0, 0, 1), (1, 0, 0, .5)),
@@ -197,7 +199,7 @@ class TestPlotImage(PlotWidgetTestCase, ParametricTestCase):
self.plot.addImage(rgba, legend="rgba",
origin=(5, 5), scale=(10, 10),
- replace=False, resetzoom=False)
+ resetzoom=False)
self.plot.resetZoom()
@@ -212,7 +214,7 @@ class TestPlotImage(PlotWidgetTestCase, ParametricTestCase):
colors=((0., 0., 0.), (1., 0., 0.),
(0., 1., 0.), (0., 0., 1.)))
self.plot.addImage(DATA_2D, legend="image 1", colormap=colormap,
- replace=False, resetzoom=False)
+ resetzoom=False)
colormap = Colormap(name=None,
normalization=Colormap.LINEAR,
@@ -224,7 +226,7 @@ class TestPlotImage(PlotWidgetTestCase, ParametricTestCase):
dtype=numpy.uint8))
self.plot.addImage(DATA_2D, legend="image 2", colormap=colormap,
origin=(DATA_2D.shape[0], 0),
- replace=False, resetzoom=False)
+ resetzoom=False)
self.plot.resetZoom()
def testImageOriginScale(self):
@@ -614,13 +616,13 @@ class TestPlotActiveCurveImage(PlotWidgetTestCase):
self.plot.getYAxis().setLabel('YLabel')
# labels changed as active curve
- self.plot.addImage(numpy.arange(100).reshape(10, 10), replace=False,
+ self.plot.addImage(numpy.arange(100).reshape(10, 10),
legend='1', xlabel='x1', ylabel='y1')
self.assertEqual(self.plot.getXAxis().getLabel(), 'x1')
self.assertEqual(self.plot.getYAxis().getLabel(), 'y1')
# labels not changed as not active curve
- self.plot.addImage(numpy.arange(100).reshape(10, 10), replace=False,
+ self.plot.addImage(numpy.arange(100).reshape(10, 10),
legend='2')
self.assertEqual(self.plot.getXAxis().getLabel(), 'x1')
self.assertEqual(self.plot.getYAxis().getLabel(), 'y1')
@@ -660,9 +662,13 @@ class TestPlotAxes(TestCaseQt, ParametricTestCase):
xData = numpy.arange(1, 10)
yData = xData ** 2
+ def __init__(self, methodName='runTest', backend=None):
+ unittest.TestCase.__init__(self, methodName)
+ self.__backend = backend
+
def setUp(self):
super(TestPlotAxes, self).setUp()
- self.plot = PlotWidget()
+ self.plot = PlotWidget(backend=self.__backend)
# It is not needed to display the plot
# It saves a lot of time
# self.plot.show()
@@ -721,7 +727,7 @@ class TestPlotAxes(TestCaseQt, ParametricTestCase):
if getter is not None:
self.assertEqual(getter(), expected)
- @testutils.test_logging(deprecation.depreclog.name, warning=2)
+ @testutils.test_logging(deprecation.depreclog.name)
def testOldPlotAxis_Logarithmic(self):
"""Test silx API prior to silx 0.6"""
x = self.plot.getXAxis()
@@ -760,7 +766,7 @@ class TestPlotAxes(TestCaseQt, ParametricTestCase):
self.assertEqual(self.plot.isYAxisLogarithmic(), False)
self.assertEqual(listener.arguments(callIndex=-1), ("y", False))
- @testutils.test_logging(deprecation.depreclog.name, warning=2)
+ @testutils.test_logging(deprecation.depreclog.name)
def testOldPlotAxis_AutoScale(self):
"""Test silx API prior to silx 0.6"""
x = self.plot.getXAxis()
@@ -799,7 +805,7 @@ class TestPlotAxes(TestCaseQt, ParametricTestCase):
self.assertEqual(self.plot.isYAxisAutoScale(), True)
self.assertEqual(listener.arguments(callIndex=-1), ("y", True))
- @testutils.test_logging(deprecation.depreclog.name, warning=1)
+ @testutils.test_logging(deprecation.depreclog.name)
def testOldPlotAxis_Inverted(self):
"""Test silx API prior to silx 0.6"""
x = self.plot.getXAxis()
@@ -1162,7 +1168,7 @@ class TestPlotImageLog(PlotWidgetTestCase):
vmax=None)
self.plot.addImage(DATA_2D, legend="image 1",
origin=(1., 1.), scale=(1., 1.),
- replace=False, resetzoom=False, colormap=colormap)
+ resetzoom=False, colormap=colormap)
self.plot.resetZoom()
def testPlotColormapGrayLogY(self):
@@ -1175,7 +1181,7 @@ class TestPlotImageLog(PlotWidgetTestCase):
vmax=None)
self.plot.addImage(DATA_2D, legend="image 1",
origin=(1., 1.), scale=(1., 1.),
- replace=False, resetzoom=False, colormap=colormap)
+ resetzoom=False, colormap=colormap)
self.plot.resetZoom()
def testPlotColormapGrayLogXY(self):
@@ -1189,7 +1195,7 @@ class TestPlotImageLog(PlotWidgetTestCase):
vmax=None)
self.plot.addImage(DATA_2D, legend="image 1",
origin=(1., 1.), scale=(1., 1.),
- replace=False, resetzoom=False, colormap=colormap)
+ resetzoom=False, colormap=colormap)
self.plot.resetZoom()
def testPlotRgbRgbaLogXY(self):
@@ -1204,7 +1210,7 @@ class TestPlotImageLog(PlotWidgetTestCase):
self.plot.addImage(rgb, legend="rgb",
origin=(1, 1), scale=(10, 10),
- replace=False, resetzoom=False)
+ resetzoom=False)
rgba = numpy.array(
(((0, 0, 0, .5), (.5, 0, 0, 1), (1, 0, 0, .5)),
@@ -1213,7 +1219,7 @@ class TestPlotImageLog(PlotWidgetTestCase):
self.plot.addImage(rgba, legend="rgba",
origin=(5., 5.), scale=(10., 10.),
- replace=False, resetzoom=False)
+ resetzoom=False)
self.plot.resetZoom()
@@ -1355,19 +1361,22 @@ class TestPlotItemLog(PlotWidgetTestCase):
def suite():
+ testClasses = (TestPlotWidget, TestPlotImage, TestPlotCurve,
+ TestPlotMarker, TestPlotItem, TestPlotAxes,
+ TestPlotEmptyLog, TestPlotCurveLog, TestPlotImageLog,
+ TestPlotMarkerLog, TestPlotItemLog)
+
test_suite = unittest.TestSuite()
- loadTests = unittest.defaultTestLoader.loadTestsFromTestCase
- test_suite.addTest(loadTests(TestPlotWidget))
- test_suite.addTest(loadTests(TestPlotImage))
- test_suite.addTest(loadTests(TestPlotCurve))
- test_suite.addTest(loadTests(TestPlotMarker))
- test_suite.addTest(loadTests(TestPlotItem))
- test_suite.addTest(loadTests(TestPlotAxes))
- test_suite.addTest(loadTests(TestPlotEmptyLog))
- test_suite.addTest(loadTests(TestPlotCurveLog))
- test_suite.addTest(loadTests(TestPlotImageLog))
- test_suite.addTest(loadTests(TestPlotMarkerLog))
- test_suite.addTest(loadTests(TestPlotItemLog))
+
+ # Tests with matplotlib
+ for testClass in testClasses:
+ test_suite.addTest(parameterize(testClass, backend=None))
+
+ if test_options.WITH_GL_TEST:
+ # Tests with OpenGL backend
+ for testClass in testClasses:
+ test_suite.addTest(parameterize(testClass, backend='gl'))
+
return test_suite