code: def test_sanity(tmp_path):
      # Segfault test
      app = QApplication([])
      ex = Example()
      assert app  # Silence warning
      assert ex  # Silence warning
  
      for mode in ("1", "RGB", "RGBA", "L", "P"):
          # to QPixmap
          im = hopper(mode)
          data = ImageQt.toqpixmap(im)
  
          assert isinstance(data, QPixmap)
          assert not data.isNull()
  
          # Test saving the file
          tempfile = str(tmp_path / f"temp_{mode}.png")
          data.save(tempfile)
  
          # Render the image
          qimage = ImageQt.ImageQt(im)
          data = QPixmap.fromImage(qimage)
          qt_format = (
              QImage.Format if ImageQt.qt_version == "6" else QImage
          )
          qimage = QImage(128, 128, qt_format.Format_ARGB32)
          painter = QPainter(qimage)
          image_label = QLabel()
          image_label.setPixmap(data)
          image_label.render(
              painter, QPoint(0, 0), QRegion(0, 0, 128, 128)
          )
          painter.end()
          rendered_tempfile = str(
              tmp_path / f"temp_rendered_{mode}.png"
          )
          qimage.save(rendered_tempfile)
          assert_image_equal_tofile(
              im.convert("RGBA"), rendered_tempfile
          )
  
          # from QPixmap
          roundtrip(hopper(mode))
  
      app.quit()
      app = None
  
imports: from __future__ import annotations
  import pytest
  from PIL import ImageQt
  from .helper import assert_image_equal_tofile, assert_image_similar, hopper
label_desc: Use image node_id 2 for calling a global function with example usage: test_sanity(tmp_path) without return types