Add a test for ErrorBarItem

This commit is contained in:
Kenneth Lyons 2019-06-08 19:57:53 -07:00
parent 1839c5ef59
commit 0c84234612

View File

@ -0,0 +1,39 @@
import pytest
from pyqtgraph.Qt import QtGui, QtCore
import pyqtgraph as pg
import numpy as np
app = pg.mkQApp()
def test_errorbaritem_defer_data():
plot = pg.PlotWidget()
plot.show()
# plot some data away from the origin to set the view rect
x = np.arange(5) + 10
curve = pg.PlotCurveItem(x=x, y=x)
plot.addItem(curve)
app.processEvents()
r_no_ebi = plot.viewRect()
# ErrorBarItem with no data shouldn't affect the view rect
err = pg.ErrorBarItem()
plot.addItem(err)
app.processEvents()
r_empty_ebi = plot.viewRect()
assert r_no_ebi == r_empty_ebi
err.setData(x=x, y=x, bottom=x, top=x)
app.processEvents()
r_ebi = plot.viewRect()
assert r_empty_ebi != r_ebi
# unset data, ErrorBarItem disappears and view rect goes back to original
err.setData(x=None, y=None)
app.processEvents()
r_clear_ebi = plot.viewRect()
assert r_clear_ebi == r_no_ebi