diff --git a/pyqtgraph/tests/test_ref_cycles.py b/pyqtgraph/tests/test_ref_cycles.py new file mode 100644 index 00000000..ac65eaf9 --- /dev/null +++ b/pyqtgraph/tests/test_ref_cycles.py @@ -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() diff --git a/pyqtgraph/tests/test_stability.py b/pyqtgraph/tests/test_stability.py new file mode 100644 index 00000000..3838af7d --- /dev/null +++ b/pyqtgraph/tests/test_stability.py @@ -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 + + + + + + +