TST: Wrap each test function in setup/teardown
This commit is contained in:
parent
7938d82a61
commit
f5aa792e7d
@ -128,9 +128,6 @@ before_script:
|
|||||||
fi;
|
fi;
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
#- cd $TRAVIS_DIR
|
|
||||||
|
|
||||||
|
|
||||||
script:
|
script:
|
||||||
|
|
||||||
- source activate test_env
|
- source activate test_env
|
||||||
|
@ -7,42 +7,6 @@ app = None
|
|||||||
win = None
|
win = None
|
||||||
vb = None
|
vb = None
|
||||||
|
|
||||||
def setup_module():
|
|
||||||
global app, win, vb, QRectF
|
|
||||||
app = pg.mkQApp()
|
|
||||||
QRectF = pg.QtCore.QRectF
|
|
||||||
qtest = pg.Qt.QtTest.QTest
|
|
||||||
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)
|
|
||||||
|
|
||||||
|
|
||||||
def teardown_module():
|
|
||||||
global app, win, vb
|
|
||||||
app.exit()
|
|
||||||
app = None
|
|
||||||
win = None
|
|
||||||
vb = None
|
|
||||||
|
|
||||||
|
|
||||||
def test_initial_shape():
|
|
||||||
w = vb.geometry().width()
|
|
||||||
h = vb.geometry().height()
|
|
||||||
|
|
||||||
view1 = QRectF(0, 0, 10, 10)
|
|
||||||
size1 = QRectF(0, h, w, -h)
|
|
||||||
_assert_mapping(vb, view1, size1)
|
|
||||||
|
|
||||||
def test_resize():
|
def test_resize():
|
||||||
# test resize
|
# test resize
|
||||||
@ -57,9 +21,6 @@ def test_resize():
|
|||||||
_assert_mapping(vb, view1, size1)
|
_assert_mapping(vb, view1, size1)
|
||||||
|
|
||||||
|
|
||||||
skipreason = ('unclear why these tests are failing. skipping until someone '
|
|
||||||
'has time to fix it.')
|
|
||||||
@pytest.mark.skipif(True, reason=skipreason)
|
|
||||||
def test_wide_resize():
|
def test_wide_resize():
|
||||||
# test wide resize
|
# test wide resize
|
||||||
win.resize(800, 400)
|
win.resize(800, 400)
|
||||||
@ -71,7 +32,6 @@ def test_wide_resize():
|
|||||||
_assert_mapping(vb, view1, size1)
|
_assert_mapping(vb, view1, size1)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(True, reason=skipreason)
|
|
||||||
def test_tall_resize():
|
def test_tall_resize():
|
||||||
# test tall resize
|
# test tall resize
|
||||||
win.resize(400, 800)
|
win.resize(400, 800)
|
||||||
@ -83,8 +43,10 @@ def test_tall_resize():
|
|||||||
_assert_mapping(vb, view1, size1)
|
_assert_mapping(vb, view1, size1)
|
||||||
|
|
||||||
|
|
||||||
|
skipreason = ('unclear why these tests are failing. skipping until someone '
|
||||||
|
'has time to fix it.')
|
||||||
@pytest.mark.skipif(True, reason=skipreason)
|
@pytest.mark.skipif(True, reason=skipreason)
|
||||||
def test_aspect_radio_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)
|
||||||
app.processEvents()
|
app.processEvents()
|
||||||
@ -105,6 +67,45 @@ def _assert_mapping(vb, r1, r2):
|
|||||||
assert vb.mapFromView(r1.bottomRight()) == r2.bottomRight()
|
assert vb.mapFromView(r1.bottomRight()) == r2.bottomRight()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
import user,sys
|
function_set = set([test_resize, test_wide_resize, test_tall_resize,
|
||||||
test_ViewBox()
|
test_aspect_ratio_constraint])
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('function', function_set)
|
||||||
|
def setup_function(function):
|
||||||
|
print('\nsetting up function %s' % function)
|
||||||
|
global app, win, vb, QRectF
|
||||||
|
app = pg.mkQApp()
|
||||||
|
QRectF = pg.QtCore.QRectF
|
||||||
|
qtest = pg.Qt.QtTest.QTest
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
g = pg.GridItem()
|
||||||
|
vb.addItem(g)
|
||||||
|
win.resize(400, 400)
|
||||||
|
vb.setAspectLocked()
|
||||||
|
win.resize(800, 400)
|
||||||
|
app.processEvents()
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('function', function_set)
|
||||||
|
def teardown_function(function):
|
||||||
|
print('\ntearing down function %s' % function)
|
||||||
|
global app, win, vb
|
||||||
|
app.exit()
|
||||||
|
app = None
|
||||||
|
win = None
|
||||||
|
vb = None
|
||||||
|
Loading…
Reference in New Issue
Block a user