From e8854d69bba513a98932efd6e3e74d0d6d1e5ad7 Mon Sep 17 00:00:00 2001 From: Ogi Date: Tue, 28 May 2019 22:41:44 -0700 Subject: [PATCH 1/5] Capture Screenshots --- pyqtgraph/tests/image_testing.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/pyqtgraph/tests/image_testing.py b/pyqtgraph/tests/image_testing.py index 2f9e98f9..c1a14c4d 100644 --- a/pyqtgraph/tests/image_testing.py +++ b/pyqtgraph/tests/image_testing.py @@ -191,6 +191,7 @@ def assertImageApproved(image, standardFile, message=None, **kwargs): if os.getenv('PYQTGRAPH_AUDIT_ALL') == '1': raise Exception("Image test passed, but auditing due to PYQTGRAPH_AUDIT_ALL evnironment variable.") except Exception: + if stdFileName in gitStatus(dataPath): print("\n\nWARNING: unit test failed against modified standard " "image %s.\nTo revert this file, run `cd %s; git checkout " @@ -210,6 +211,9 @@ def assertImageApproved(image, standardFile, message=None, **kwargs): "PYQTGRAPH_AUDIT=1 to add this image." % stdFileName) else: if os.getenv('TRAVIS') is not None: + saveFailedTest(image, stdImage, standardFile, upload=True) + elif os.getenv('AZURE') is not None: + standardFile = r"artifacts/" + standardFile saveFailedTest(image, stdImage, standardFile) print(graphstate) raise @@ -281,14 +285,13 @@ def assertImageMatch(im1, im2, minCorr=None, pxThreshold=50., assert corr >= minCorr -def saveFailedTest(data, expect, filename): +def saveFailedTest(data, expect, filename, upload=False): """Upload failed test images to web server to allow CI test debugging. """ commit = runSubprocess(['git', 'rev-parse', 'HEAD']) name = filename.split('/') name.insert(-1, commit.strip()) filename = '/'.join(name) - host = 'data.pyqtgraph.org' # concatenate data, expect, and diff into a single image ds = data.shape @@ -306,15 +309,25 @@ def saveFailedTest(data, expect, filename): img[2:2+diff.shape[0], -diff.shape[1]-2:-2] = diff png = makePng(img) + directory, _, _ = filename.rpartition("/") + if not os.path.isdir(directory): + os.makedirs(directory) + with open(filename + ".png", "wb") as png_file: + png_file.write(png) + print("\nImage comparison failed. Test result: %s %s Expected result: " + "%s %s" % (data.shape, data.dtype, expect.shape, expect.dtype)) + if upload: + uploadFailedTest(filename) +def uploadFailedTest(filename): + host = 'data.pyqtgraph.org' conn = httplib.HTTPConnection(host) req = urllib.urlencode({'name': filename, 'data': base64.b64encode(png)}) conn.request('POST', '/upload.py', req) response = conn.getresponse().read() conn.close() - print("\nImage comparison failed. Test result: %s %s Expected result: " - "%s %s" % (data.shape, data.dtype, expect.shape, expect.dtype)) + print("Uploaded to: \nhttp://%s/data/%s" % (host, filename)) if not response.startswith(b'OK'): print("WARNING: Error uploading data to %s" % host) @@ -495,7 +508,7 @@ def getTestDataRepo(): if not os.path.isdir(parentPath): os.makedirs(parentPath) - if os.getenv('TRAVIS') is not None: + if os.getenv('TRAVIS') is not None or os.getenv('AZURE') is not None: # Create a shallow clone of the test-data repository (to avoid # downloading more data than is necessary) os.makedirs(dataPath) From f2aeea8964992ddedf0f5b1d92882d9c8629dc0a Mon Sep 17 00:00:00 2001 From: Ogi Date: Tue, 28 May 2019 22:42:01 -0700 Subject: [PATCH 2/5] We support pyside2 don't we? --- examples/__main__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/__main__.py b/examples/__main__.py index 9c49bb3b..0251974a 100644 --- a/examples/__main__.py +++ b/examples/__main__.py @@ -135,6 +135,8 @@ if __name__ == '__main__': lib = 'PyQt4' elif '--pyqt5' in args: lib = 'PyQt5' + elif '--pyside2' in args: + lib = 'PySide2' else: lib = '' From aa63c07523dbb1f1ad9e38ef80e06a5e8eb3893d Mon Sep 17 00:00:00 2001 From: Ogi Date: Tue, 28 May 2019 22:42:25 -0700 Subject: [PATCH 3/5] Show available desktop resolution --- pyqtgraph/graphicsItems/ViewBox/tests/test_ViewBox.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyqtgraph/graphicsItems/ViewBox/tests/test_ViewBox.py b/pyqtgraph/graphicsItems/ViewBox/tests/test_ViewBox.py index 68f4f497..a42fb5f9 100644 --- a/pyqtgraph/graphicsItems/ViewBox/tests/test_ViewBox.py +++ b/pyqtgraph/graphicsItems/ViewBox/tests/test_ViewBox.py @@ -31,7 +31,8 @@ def init_viewbox(): g = pg.GridItem() vb.addItem(g) - + desktop = app.desktop().screenGeometry() + print("\n\nDesktop Resolution: {} x {}\n\n".format(desktop.width(), desktop.height())) app.processEvents() def test_ViewBox(): From c4e295ceae9e783b23c54fe24b13b00ef45c8125 Mon Sep 17 00:00:00 2001 From: Ogi Moore Date: Wed, 29 May 2019 10:53:04 -0700 Subject: [PATCH 4/5] Use correct path seperators, pass png to upload function --- pyqtgraph/tests/image_testing.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pyqtgraph/tests/image_testing.py b/pyqtgraph/tests/image_testing.py index c1a14c4d..564e6d46 100644 --- a/pyqtgraph/tests/image_testing.py +++ b/pyqtgraph/tests/image_testing.py @@ -289,9 +289,9 @@ def saveFailedTest(data, expect, filename, upload=False): """Upload failed test images to web server to allow CI test debugging. """ commit = runSubprocess(['git', 'rev-parse', 'HEAD']) - name = filename.split('/') + name = filename.split(os.path.sep) name.insert(-1, commit.strip()) - filename = '/'.join(name) + filename = os.path.sep.join(name) # concatenate data, expect, and diff into a single image ds = data.shape @@ -309,7 +309,7 @@ def saveFailedTest(data, expect, filename, upload=False): img[2:2+diff.shape[0], -diff.shape[1]-2:-2] = diff png = makePng(img) - directory, _, _ = filename.rpartition("/") + directory = os.path.dirname(filename) if not os.path.isdir(directory): os.makedirs(directory) with open(filename + ".png", "wb") as png_file: @@ -317,9 +317,9 @@ def saveFailedTest(data, expect, filename, upload=False): print("\nImage comparison failed. Test result: %s %s Expected result: " "%s %s" % (data.shape, data.dtype, expect.shape, expect.dtype)) if upload: - uploadFailedTest(filename) + uploadFailedTest(filename, png) -def uploadFailedTest(filename): +def uploadFailedTest(filename, png): host = 'data.pyqtgraph.org' conn = httplib.HTTPConnection(host) req = urllib.urlencode({'name': filename, From 4b26519feffe03954e6ca45ace108b05c514aafa Mon Sep 17 00:00:00 2001 From: Ogi Moore Date: Wed, 29 May 2019 13:07:08 -0700 Subject: [PATCH 5/5] Move Desktop Resolution info print statement to test.py --- pyqtgraph/graphicsItems/ViewBox/tests/test_ViewBox.py | 2 -- test.py | 7 ++++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pyqtgraph/graphicsItems/ViewBox/tests/test_ViewBox.py b/pyqtgraph/graphicsItems/ViewBox/tests/test_ViewBox.py index a42fb5f9..bb705c18 100644 --- a/pyqtgraph/graphicsItems/ViewBox/tests/test_ViewBox.py +++ b/pyqtgraph/graphicsItems/ViewBox/tests/test_ViewBox.py @@ -31,8 +31,6 @@ def init_viewbox(): g = pg.GridItem() vb.addItem(g) - desktop = app.desktop().screenGeometry() - print("\n\nDesktop Resolution: {} x {}\n\n".format(desktop.width(), desktop.height())) app.processEvents() def test_ViewBox(): diff --git a/test.py b/test.py index b07fb1cf..63656d68 100644 --- a/test.py +++ b/test.py @@ -15,10 +15,15 @@ elif '--pyqt4' in args: elif '--pyqt5' in args: args.remove('--pyqt5') import PyQt5 +elif '--pyside2' in args: + args.remove('--pyside2') + import PySide2 import pyqtgraph as pg pg.systemInfo() - +qApp = pg.mkQApp() +desktop = qApp.desktop().screenGeometry() +print("\n\nDesktop Resolution: {} x {}\n\n".format(desktop.width(), desktop.height())) pytest.main(args) \ No newline at end of file