code: def test_check_niimg_wildcards_errors():
      nofile_path = "/tmp/nofile"
      nofile_path_wildcards = "/tmp/no*file"
      wildcards_msg = (
          "No files matching the entered niimg expression: "
          "'%s'.\n You may have left wildcards usage "
          "activated: please set the global constant "
          "'nilearn.EXPAND_PATH_WILDCARDS' to False to "
          "deactivate this behavior."
      )
  
      file_not_found_msg = "File not found: '%s'"
  
      # Check bad filename
      # Non existing file (with no magic) raise a ValueError exception
      with pytest.raises(
          ValueError, match=file_not_found_msg % nofile_path
      ):
          _utils.check_niimg(nofile_path)
      # Non matching wildcard raises a ValueError exception
      with pytest.raises(
          ValueError,
          match=wildcards_msg % re.escape(nofile_path_wildcards),
      ):
          _utils.check_niimg(nofile_path_wildcards)
  
imports: import os
  import re
  import tempfile
  from pathlib import Path
  import nibabel
  import numpy
  import pytest
  from nibabel import Nifti1Image
  from numpy.testing import assert_array_equal
  import nilearn
  from nilearn import _utils
  from nilearn._utils import niimg_conversions, testing
  from nilearn._utils.exceptions import DimensionError
  from nilearn._utils.niimg_conversions import iter_check_niimg
  from nilearn._utils.testing import assert_memory_less_than, with_memory_profiler
  from nilearn.image import get_data
label_desc: Use image node_id 7 for calling a global function with example usage: test_check_niimg_wildcards_errors() without return types