TST: Wheeee overengineered solution!
This commit is contained in:
parent
26ee8d5aaa
commit
2b075560c7
@ -2,17 +2,18 @@
|
|||||||
import pyqtgraph as pg
|
import pyqtgraph as pg
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
QRectF = None
|
QRectF = pg.QtCore.QRectF
|
||||||
app = None
|
qtest = pg.Qt.QtTest.QTest
|
||||||
|
app = pg.mkQApp()
|
||||||
win = None
|
win = None
|
||||||
vb = None
|
vb = None
|
||||||
|
|
||||||
|
|
||||||
def test_resize():
|
def test_resize():
|
||||||
|
global app, win, vb
|
||||||
# test resize
|
# test resize
|
||||||
win.resize(400, 400)
|
win.resize(400, 400)
|
||||||
app.processEvents()
|
app.processEvents()
|
||||||
|
|
||||||
w = vb.geometry().width()
|
w = vb.geometry().width()
|
||||||
h = vb.geometry().height()
|
h = vb.geometry().height()
|
||||||
view1 = QRectF(0, 0, 10, 10)
|
view1 = QRectF(0, 0, 10, 10)
|
||||||
@ -22,6 +23,9 @@ def test_resize():
|
|||||||
|
|
||||||
|
|
||||||
def test_wide_resize():
|
def test_wide_resize():
|
||||||
|
global app, win, vb
|
||||||
|
win.resize(400,400)
|
||||||
|
vb.setAspectLocked()
|
||||||
# test wide resize
|
# test wide resize
|
||||||
win.resize(800, 400)
|
win.resize(800, 400)
|
||||||
app.processEvents()
|
app.processEvents()
|
||||||
@ -33,6 +37,7 @@ def test_wide_resize():
|
|||||||
|
|
||||||
|
|
||||||
def test_tall_resize():
|
def test_tall_resize():
|
||||||
|
global app, win, vb
|
||||||
# test tall resize
|
# test tall resize
|
||||||
win.resize(400, 800)
|
win.resize(400, 800)
|
||||||
app.processEvents()
|
app.processEvents()
|
||||||
@ -45,7 +50,7 @@ def test_tall_resize():
|
|||||||
|
|
||||||
skipreason = ('unclear why these tests are failing. skipping until someone '
|
skipreason = ('unclear why these tests are failing. skipping until someone '
|
||||||
'has time to fix it.')
|
'has time to fix it.')
|
||||||
@pytest.mark.skipif(True, reason=skipreason)
|
# @pytest.mark.skipif(True, reason=skipreason)
|
||||||
def test_aspect_ratio_constraint():
|
def test_aspect_ratio_constraint():
|
||||||
# test limits + resize (aspect ratio constraint has priority over limits
|
# test limits + resize (aspect ratio constraint has priority over limits
|
||||||
win.resize(400, 400)
|
win.resize(400, 400)
|
||||||
@ -73,11 +78,7 @@ function_set = set([test_resize, test_wide_resize, test_tall_resize,
|
|||||||
|
|
||||||
@pytest.mark.parametrize('function', function_set)
|
@pytest.mark.parametrize('function', function_set)
|
||||||
def setup_function(function):
|
def setup_function(function):
|
||||||
print('\nsetting up function %s' % function)
|
global app, win, vb
|
||||||
global app, win, vb, QRectF
|
|
||||||
app = pg.mkQApp()
|
|
||||||
QRectF = pg.QtCore.QRectF
|
|
||||||
qtest = pg.Qt.QtTest.QTest
|
|
||||||
|
|
||||||
win = pg.GraphicsWindow()
|
win = pg.GraphicsWindow()
|
||||||
win.ci.layout.setContentsMargins(0,0,0,0)
|
win.ci.layout.setContentsMargins(0,0,0,0)
|
||||||
@ -93,26 +94,21 @@ def setup_function(function):
|
|||||||
|
|
||||||
g = pg.GridItem()
|
g = pg.GridItem()
|
||||||
vb.addItem(g)
|
vb.addItem(g)
|
||||||
|
|
||||||
g = pg.GridItem()
|
|
||||||
vb.addItem(g)
|
|
||||||
win.resize(400, 400)
|
|
||||||
|
|
||||||
w = vb.geometry().width()
|
w = vb.geometry().width()
|
||||||
h = vb.geometry().height()
|
h = vb.geometry().height()
|
||||||
view1 = QRectF(0, 0, 10, 10)
|
view1 = QRectF(0, 0, 10, 10)
|
||||||
size1 = QRectF(0, h, w, -h)
|
size1 = QRectF(0, h, w, -h)
|
||||||
|
|
||||||
_assert_mapping(vb, view1, size1)
|
_assert_mapping(vb, view1, size1)
|
||||||
|
|
||||||
|
win.resize(400, 400)
|
||||||
|
|
||||||
vb.setAspectLocked()
|
vb.setAspectLocked()
|
||||||
win.resize(800, 400)
|
win.resize(800, 400)
|
||||||
app.processEvents()
|
app.processEvents()
|
||||||
|
|
||||||
@pytest.mark.parametrize('function', function_set)
|
@pytest.mark.parametrize('function', function_set)
|
||||||
def teardown_function(function):
|
def teardown_function(function):
|
||||||
print('\ntearing down function %s' % function)
|
global win, vb
|
||||||
global app, win, vb
|
|
||||||
app.exit()
|
|
||||||
app = None
|
|
||||||
win = None
|
win = None
|
||||||
vb = None
|
vb = None
|
||||||
|
Loading…
Reference in New Issue
Block a user