TST: Wrap each test function in setup/teardown

This commit is contained in:
Eric Dill 2015-07-31 13:31:54 -04:00
parent 7938d82a61
commit f5aa792e7d
2 changed files with 48 additions and 50 deletions

View File

@ -113,12 +113,12 @@ before_script:
start_test "repo size check";
mkdir ~/repo-clone && cd ~/repo-clone &&
git init && git remote add -t ${TRAVIS_BRANCH} origin git://github.com/${TRAVIS_REPO_SLUG}.git &&
git fetch origin ${GIT_TARGET_EXTRA} &&
git checkout -qf FETCH_HEAD &&
git fetch origin ${GIT_TARGET_EXTRA} &&
git checkout -qf FETCH_HEAD &&
git tag travis-merge-target &&
git gc --aggressive &&
TARGET_SIZE=`du -s . | sed -e "s/\t.*//"` &&
git pull origin ${GIT_SOURCE_EXTRA} &&
git pull origin ${GIT_SOURCE_EXTRA} &&
git gc --aggressive &&
MERGE_SIZE=`du -s . | sed -e "s/\t.*//"` &&
if [ "${MERGE_SIZE}" != "${TARGET_SIZE}" ]; then
@ -127,9 +127,6 @@ before_script:
SIZE_DIFF=0;
fi;
fi;
#- cd $TRAVIS_DIR
script:

View File

@ -7,42 +7,6 @@ app = None
win = 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():
# test resize
@ -57,9 +21,6 @@ def test_resize():
_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():
# test wide resize
win.resize(800, 400)
@ -71,7 +32,6 @@ def test_wide_resize():
_assert_mapping(vb, view1, size1)
@pytest.mark.skipif(True, reason=skipreason)
def test_tall_resize():
# test tall resize
win.resize(400, 800)
@ -83,8 +43,10 @@ def test_tall_resize():
_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_aspect_radio_constraint():
def test_aspect_ratio_constraint():
# test limits + resize (aspect ratio constraint has priority over limits
win.resize(400, 400)
app.processEvents()
@ -105,6 +67,45 @@ def _assert_mapping(vb, r1, r2):
assert vb.mapFromView(r1.bottomRight()) == r2.bottomRight()
if __name__ == '__main__':
import user,sys
test_ViewBox()
function_set = set([test_resize, test_wide_resize, test_tall_resize,
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