From c58a177561829920fadfdcc1fbee2160f44126b3 Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Tue, 1 Nov 2016 18:28:48 -0700 Subject: [PATCH] Relax image test requirements for Qt5 (there are some single-pixel shifts that we will nee new test images to cover) --- pyqtgraph/tests/image_testing.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pyqtgraph/tests/image_testing.py b/pyqtgraph/tests/image_testing.py index f4404671..c8a41dec 100644 --- a/pyqtgraph/tests/image_testing.py +++ b/pyqtgraph/tests/image_testing.py @@ -59,7 +59,7 @@ if sys.version[0] >= '3': else: import httplib import urllib -from ..Qt import QtGui, QtCore, QtTest +from ..Qt import QtGui, QtCore, QtTest, QT_LIB from .. import functions as fn from .. import GraphicsLayoutWidget from .. import ImageItem, TextItem @@ -212,7 +212,7 @@ def assertImageApproved(image, standardFile, message=None, **kwargs): def assertImageMatch(im1, im2, minCorr=None, pxThreshold=50., - pxCount=0, maxPxDiff=None, avgPxDiff=None, + pxCount=-1, maxPxDiff=None, avgPxDiff=None, imgDiff=None): """Check that two images match. @@ -234,7 +234,8 @@ def assertImageMatch(im1, im2, minCorr=None, pxThreshold=50., pxThreshold : float Minimum value difference at which two pixels are considered different pxCount : int or None - Maximum number of pixels that may differ + Maximum number of pixels that may differ. Default is 0 for Qt4 and + 1% of image size for Qt5. maxPxDiff : float or None Maximum allowed difference between pixels avgPxDiff : float or None @@ -247,6 +248,14 @@ def assertImageMatch(im1, im2, minCorr=None, pxThreshold=50., assert im1.shape[2] == 4 assert im1.dtype == im2.dtype + if pxCount == -1: + if QT_LIB == 'PyQt5': + # Qt5 generates slightly different results; relax the tolerance + # until test images are updated. + pxCount = int(im1.shape[0] * im1.shape[1] * 0.01) + else: + pxCount = 0 + diff = im1.astype(float) - im2.astype(float) if imgDiff is not None: assert np.abs(diff).sum() <= imgDiff