code: def test_load_surf_mesh_file_gii(tmp_path):
      # Test the loader `load_surf_mesh`
      mesh = generate_surf()
  
      # test if correct gii is loaded into correct list
      fd_mesh, filename_gii_mesh = tempfile.mkstemp(
          suffix=".gii", dir=str(tmp_path)
      )
      os.close(fd_mesh)
      coord_array = gifti.GiftiDataArray(
          data=mesh[0],
          intent=nb.nifti1.intent_codes["NIFTI_INTENT_POINTSET"],
          datatype="NIFTI_TYPE_FLOAT32",
      )
      face_array = gifti.GiftiDataArray(
          data=mesh[1],
          intent=nb.nifti1.intent_codes["NIFTI_INTENT_TRIANGLE"],
          datatype="NIFTI_TYPE_FLOAT32",
      )
  
      gii = gifti.GiftiImage(darrays=[coord_array, face_array])
      nb.save(gii, filename_gii_mesh)
      assert_array_almost_equal(
          load_surf_mesh(filename_gii_mesh)[0], mesh[0]
      )
      assert_array_almost_equal(
          load_surf_mesh(filename_gii_mesh)[1], mesh[1]
      )
      os.remove(filename_gii_mesh)
  
      # test if incorrect gii raises error
      fd_no, filename_gii_mesh_no_point = tempfile.mkstemp(
          suffix=".gii", dir=str(tmp_path)
      )
      os.close(fd_no)
      nb.save(
          gifti.GiftiImage(darrays=[face_array, face_array]),
          filename_gii_mesh_no_point,
      )
      with pytest.raises(ValueError, match="NIFTI_INTENT_POINTSET"):
          load_surf_mesh(filename_gii_mesh_no_point)
      os.remove(filename_gii_mesh_no_point)
  
      fd_face, filename_gii_mesh_no_face = tempfile.mkstemp(
          suffix=".gii", dir=str(tmp_path)
      )
      os.close(fd_face)
      nb.save(
          gifti.GiftiImage(darrays=[coord_array, coord_array]),
          filename_gii_mesh_no_face,
      )
      with pytest.raises(ValueError, match="NIFTI_INTENT_TRIANGLE"):
          load_surf_mesh(filename_gii_mesh_no_face)
      os.remove(filename_gii_mesh_no_face)
  
imports: import os
  import tempfile
  import warnings
  import nibabel
  import numpy
  import pytest
  from nibabel import gifti
  from numpy.testing import assert_array_almost_equal, assert_array_equal
  from scipy.spatial import Delaunay
  from scipy.stats import pearsonr
  from nilearn import datasets, image
  from nilearn._utils import data_gen
  from nilearn.image import resampling
  from nilearn.surface import Mesh, Surface, load_surf_data, load_surf_mesh, surface
  from nilearn.surface.surface import _gifti_img_to_mesh, _load_surf_files_gifti_gzip
  from nilearn.surface.tests._testing import flat_mesh, generate_surf, z_const_img
label_desc: Use image node_id 12 for calling a global function with example usage: test_load_surf_mesh_file_gii(tmp_path) without return types