Close windows at the end of test functions (#1042)

* Close windows at the end of test functions

* Can't show window deletion warning during interpreter shutdown
starting
This commit is contained in:
Kenneth Lyons 2019-09-27 13:37:40 -07:00 committed by Ogi Moore
parent 071e429535
commit 61ec73a741
7 changed files with 16 additions and 2 deletions

View File

@ -28,6 +28,7 @@ def test_plotscene():
ex.export(fileName=tempfilename)
# clean up after the test is done
os.unlink(tempfilename)
w.close()
def test_simple():
tempfilename = tempfile.NamedTemporaryFile(suffix='.svg').name

View File

@ -71,6 +71,8 @@ def test_ViewBox():
size1 = QRectF(0, h, w, -h)
assertMapping(vb, view1, size1)
win.close()
skipreason = "Skipping this test until someone has time to fix it."
@pytest.mark.skipif(True, reason=skipreason)

View File

@ -28,3 +28,5 @@ def test_AxisItem_stopAxisAtTick(monkeypatch):
monkeypatch.setattr(left, "drawPicture", test_left)
plot.show()
app.processEvents()
plot.close()

View File

@ -35,3 +35,5 @@ def test_ErrorBarItem_defer_data():
r_clear_ebi = plot.viewRect()
assert r_clear_ebi == r_no_ebi
plot.close()

View File

@ -27,7 +27,8 @@ def test_PlotCurveItem():
c.setData(data, connect=np.array([1,1,1,0,1,1,0,0,1,0,0,0,1,1,0,0]))
assertImageApproved(p, 'plotcurveitem/connectarray', "Plot curve with connection array.")
p.close()
if __name__ == '__main__':

View File

@ -86,3 +86,5 @@ def test_clipping():
assert xDisp[0] <= vr.left()
assert xDisp[-1] >= vr.right()
w.close()

View File

@ -411,7 +411,11 @@ class GraphicsView(QtGui.QGraphicsView):
try:
if self.parentWidget() is None and self.isVisible():
msg = "Visible window deleted. To prevent this, store a reference to the window object."
warnings.warn(msg, RuntimeWarning, stacklevel=2)
try:
warnings.warn(msg, RuntimeWarning, stacklevel=2)
except TypeError:
# warnings module not available during interpreter shutdown
pass
except RuntimeError:
pass