Commit 8dd7f071 authored by Luke Campagnola's avatar Luke Campagnola
Browse files

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
parent 5a8d77d6
"""
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()
"""
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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment