e7a30b9324
Remove if __name__ == "__main__" bits, replace some == None to is None checks Cleanup variety of static code checker issue Removed missing imports, restructured some logic to make a little cleaner, fixed a function in test_dockarea, unfortunately broke the test so now I tell pytest to expect the Exception.
31 lines
716 B
Python
31 lines
716 B
Python
import weakref
|
|
import pyqtgraph as pg
|
|
import faulthandler
|
|
faulthandler.enable()
|
|
|
|
pg.mkQApp()
|
|
|
|
def test_getViewWidget():
|
|
view = pg.PlotWidget()
|
|
vref = weakref.ref(view)
|
|
item = pg.InfiniteLine()
|
|
view.addItem(item)
|
|
assert item.getViewWidget() is view
|
|
del view
|
|
assert vref() is None
|
|
assert item.getViewWidget() is None
|
|
|
|
def test_getViewWidget_deleted():
|
|
view = pg.PlotWidget()
|
|
item = pg.InfiniteLine()
|
|
view.addItem(item)
|
|
assert item.getViewWidget() is view
|
|
|
|
# Arrange to have Qt automatically delete the view widget
|
|
obj = pg.QtGui.QWidget()
|
|
view.setParent(obj)
|
|
del obj
|
|
|
|
assert not pg.Qt.isQObjectAlive(view)
|
|
assert item.getViewWidget() is None
|