Start stability tests:

- randomly add / remove widgets and graphicsitems to provoke a crash
 - create and delete various objects and ensure that nothing is left in memory
This commit is contained in:
Luke Campagnola 2014-04-03 13:37:07 -04:00
parent 5a8d77d6f2
commit 8dd7f07158
2 changed files with 84 additions and 0 deletions

View File

@ -0,0 +1,45 @@
"""
Test for unwanted reference cycles
"""
import pyqtgraph as pg
import numpy as np
import gc
app = pg.mkQApp()
def processEvents():
for i in range(3):
gc.collect()
app.processEvents()
# processEvents ignored DeferredDelete events; we must process these
# manually.
app.sendPostedEvents(None, pg.QtCore.QEvent.DeferredDelete)
def test_PlotItem():
for i in range(10):
plt = pg.PlotItem()
plt.plot(np.random.normal(size=10000))
processEvents()
ot = pg.debug.ObjTracker()
plots = []
for i in range(10):
plt = pg.PlotItem()
plt.plot(np.random.normal(size=10000))
plots.append(plt)
processEvents()
ot.diff()
del plots
processEvents()
ot.diff()
return ot
if __name__ == '__main__':
ot = test_PlotItem()

View File

@ -0,0 +1,39 @@
"""
PyQt/PySide stress test:
Create lots of random widgets and graphics items, connect them together randomly,
the tear them down repeatedly.
The purpose of this is to attempt to generate segmentation faults.
"""
import pyqtgraph as pg
import random
random.seed(12345)
widgetTypes = [pg.PlotWidget, pg.ImageView, pg.GraphicsView, pg.QtGui.QWidget,
pg.QtGui.QTreeWidget, pg.QtGui.QPushButton]
itemTypes = [pg.PlotCurveItem, pg.ImageItem, pg.PlotDataItem, pg.ViewBox,
pg.QtGui.QGraphicsRectItem]
while True:
action = random.randint(0,5)
if action == 0:
# create a widget
pass
elif action == 1:
# set parent (widget or None), possibly create a reference in either direction
pass
elif action == 2:
#
pass
elif action == 3:
pass