code: def test_npz_reading_writing(tmp_path):
      """Test reading and saveing npz"""
  
      if IS_PYPY:
          return  # no support for npz format :(
  
      im2 = np.ones((10, 10), np.uint8) * 2
      im3 = np.ones((10, 10, 10), np.uint8) * 3
      im4 = np.ones((10, 10, 10, 10), np.uint8) * 4
  
      filename1 = tmp_path / "test_npz.npz"
  
      # One image
      iio.imsave(filename1, im2)
      im = iio.imread(filename1)
      ims = iio.mimread(filename1)
      assert (im == im2).all()
      assert len(ims) == 1
  
      # Multiple images
      iio.mimsave(filename1, [im2, im2, im2])
      im = iio.imread(filename1)
      ims = iio.mimread(filename1)
      assert (im == im2).all()
      assert len(ims) == 3
  
      # Volumes
      iio.mvolsave(filename1, [im3, im3])
      im = iio.volread(filename1)
      ims = iio.mvolread(filename1)
      assert (im == im3).all()
      assert len(ims) == 2
  
      # Mixed
      W = iio.save(filename1)
      assert W.format.name == "NPZ"
      W.append_data(im2)
      W.append_data(im3)
      W.append_data(im4)
      pytest.raises(
          RuntimeError, W.set_meta_data, {}
      )  # no meta data support
      W.close()
      #
      R = iio.read(filename1)
      assert R.format.name == "NPZ"
      ims = list(R)  # == [im for im in R]
      assert (ims[0] == im2).all()
      assert (ims[1] == im3).all()
      assert (ims[2] == im4).all()
      # Fail
      pytest.raises(IndexError, R.get_data, -1)
      pytest.raises(IndexError, R.get_data, 3)
      pytest.raises(
          RuntimeError, R.get_meta_data, None
      )  # no meta data support
      pytest.raises(RuntimeError, R.get_meta_data, 0)
  
imports: import pytest
  import numpy
  import imageio.v2
  from imageio.core import Request, IS_PYPY
  from conftest import deprecated_test
label_desc: Use image node_id 2 for calling a global function with example usage: test_npz_reading_writing(tmp_path) without return types