From cb326c4fd71f030d8f3b2a5d585431bf7df01d93 Mon Sep 17 00:00:00 2001 From: Eric Dill Date: Fri, 31 Jul 2015 14:42:31 -0400 Subject: [PATCH] TST: But I should not just copy/paste code... --- .../ViewBox/tests/test_ViewBox.py | 33 ++++++------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/pyqtgraph/graphicsItems/ViewBox/tests/test_ViewBox.py b/pyqtgraph/graphicsItems/ViewBox/tests/test_ViewBox.py index 34e65292..624d7812 100644 --- a/pyqtgraph/graphicsItems/ViewBox/tests/test_ViewBox.py +++ b/pyqtgraph/graphicsItems/ViewBox/tests/test_ViewBox.py @@ -3,6 +3,7 @@ import pyqtgraph as pg app = pg.mkQApp() qtest = pg.Qt.QtTest.QTest +QRectF = pg.QtCore.QRectF def assertMapping(vb, r1, r2): assert vb.mapFromView(r1.topLeft()) == r2.topLeft() @@ -10,9 +11,10 @@ def assertMapping(vb, r1, r2): assert vb.mapFromView(r1.topRight()) == r2.topRight() assert vb.mapFromView(r1.bottomRight()) == r2.bottomRight() -def test_ViewBox(): - global app, win, vb - QRectF = pg.QtCore.QRectF +def init_viewbox(): + """Helper function to init the ViewBox + """ + global win, vb win = pg.GraphicsWindow() win.ci.layout.setContentsMargins(0,0,0,0) @@ -31,6 +33,9 @@ def test_ViewBox(): app.processEvents() +def test_ViewBox(): + init_viewbox() + w = vb.geometry().width() h = vb.geometry().height() view1 = QRectF(0, 0, 10, 10) @@ -68,26 +73,8 @@ def test_ViewBox(): def test_limits_and_resize(): - global app, win, vb - QRectF = pg.QtCore.QRectF - - win = pg.GraphicsWindow() - win.ci.layout.setContentsMargins(0,0,0,0) - win.resize(200, 200) - win.show() - vb = win.addViewBox() - - # set range before viewbox is shown - vb.setRange(xRange=[0, 10], yRange=[0, 10], padding=0) - - # required to make mapFromView work properly. - qtest.qWaitForWindowShown(win) - - g = pg.GridItem() - vb.addItem(g) - - app.processEvents() - + init_viewbox() + # now lock aspect vb.setAspectLocked() # test limits + resize (aspect ratio constraint has priority over limits