code: def test_mouseInteraction():
      # disable delay of mouse move events because events is called immediately in test
      pg.setConfigOption("mouseRateLimit", -1)
  
      plt = pg.PlotWidget()
      plt.show()
      plt.scene().minDragTime = (
          0  # let us simulate mouse drags very quickly.
      )
      vline = plt.addLine(x=0, movable=True)
      hline = plt.addLine(y=0, movable=True)
      hline2 = plt.addLine(y=-1, movable=False)
      plt.setXRange(-10, 10)
      plt.setYRange(-10, 10)
  
      # test horizontal drag
      pos = plt.plotItem.vb.mapViewToScene(pg.Point(0, 5))
      pos2 = pos - QtCore.QPointF(200, 200)
      mouseMove(plt, pos)
      assert (
          vline.mouseHovering is True and hline.mouseHovering is False
      )
      mouseDrag(plt, pos, pos2, QtCore.Qt.MouseButton.LeftButton)
      px = vline.pixelLength(pg.Point(1, 0), ortho=True)
      assert (
          abs(vline.value() - plt.plotItem.vb.mapSceneToView(pos2).x())
          <= px
      )
  
      # test missed drag
      pos = plt.plotItem.vb.mapViewToScene(pg.Point(5, 0))
      pos = pos + QtCore.QPointF(0, 6)
      pos2 = pos + QtCore.QPointF(-20, -20)
      mouseMove(plt, pos)
      assert (
          vline.mouseHovering is False and hline.mouseHovering is False
      )
      mouseDrag(plt, pos, pos2, QtCore.Qt.MouseButton.LeftButton)
      assert hline.value() == 0
  
      # test vertical drag
      pos = plt.plotItem.vb.mapViewToScene(pg.Point(5, 0))
      pos2 = pos - QtCore.QPointF(50, 50)
      mouseMove(plt, pos)
      assert (
          vline.mouseHovering is False and hline.mouseHovering is True
      )
      mouseDrag(plt, pos, pos2, QtCore.Qt.MouseButton.LeftButton)
      px = hline.pixelLength(pg.Point(1, 0), ortho=True)
      assert (
          abs(hline.value() - plt.plotItem.vb.mapSceneToView(pos2).y())
          <= px
      )
  
      # test non-interactive line
      pos = plt.plotItem.vb.mapViewToScene(pg.Point(5, -1))
      pos2 = pos - QtCore.QPointF(50, 50)
      mouseMove(plt, pos)
      assert hline2.mouseHovering == False
      mouseDrag(plt, pos, pos2, QtCore.Qt.MouseButton.LeftButton)
      assert hline2.value() == -1
      plt.close()
  
imports: import pyqtgraph
  from pyqtgraph.Qt import QtCore, QtGui, QtTest
  from tests.ui_testing import mouseDrag, mouseMove
label_desc: Use image node_id 2 for calling a global function with example usage: test_mouseInteraction() without return types