Add a test for ErrorBarItem
This commit is contained in:
parent
1839c5ef59
commit
0c84234612
39
pyqtgraph/graphicsItems/tests/test_ErrorBarItem.py
Normal file
39
pyqtgraph/graphicsItems/tests/test_ErrorBarItem.py
Normal 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
|
Loading…
Reference in New Issue
Block a user