code: def test_data_path(with_nimd_env):
      # wipe out any sources of data paths
      if DATA_KEY in env:
          del env[DATA_KEY]
      if USER_KEY in env:
          del os.environ[USER_KEY]
      fake_user_dir = "/user/path"
      nibd.get_nipy_system_dir = lambda: "/unlikely/path"
      nibd.get_nipy_user_dir = lambda: fake_user_dir
      # now we should only have anything pointed to in the user's dir
      old_pth = get_data_path()
      # We should have only sys.prefix and, iff sys.prefix == /usr,
      # '/usr/local'.  This last to is deal with Debian patching to
      # distutils.
      def_dirs = [pjoin(sys.prefix, "share", "nipy")]
      if sys.prefix == "/usr":
          def_dirs.append(pjoin("/usr/local", "share", "nipy"))
      assert old_pth == def_dirs + ["/user/path"]
      # then we'll try adding some of our own
      tst_pth = "/a/path" + os.path.pathsep + "/b/ path"
      tst_list = ["/a/path", "/b/ path"]
      # First, an environment variable
      os.environ[DATA_KEY] = tst_list[0]
      assert get_data_path() == tst_list[:1] + old_pth
      os.environ[DATA_KEY] = tst_pth
      assert get_data_path() == tst_list + old_pth
      del os.environ[DATA_KEY]
      # Next, make a fake user directory, and put a file in there
      with TemporaryDirectory() as tmpdir:
          tmpfile = pjoin(tmpdir, "config.ini")
          with open(tmpfile, "w") as fobj:
              fobj.write("[DATA]\n")
              fobj.write(f"path = {tst_pth}")
          nibd.get_nipy_user_dir = lambda: tmpdir
          assert get_data_path() == tst_list + def_dirs + [tmpdir]
      nibd.get_nipy_user_dir = lambda: fake_user_dir
      assert get_data_path() == old_pth
      # with some trepidation, the system config files
      with TemporaryDirectory() as tmpdir:
          nibd.get_nipy_system_dir = lambda: tmpdir
          tmpfile = pjoin(tmpdir, "an_example.ini")
          with open(tmpfile, "w") as fobj:
              fobj.write("[DATA]\n")
              fobj.write(f"path = {tst_pth}\n")
          tmpfile = pjoin(tmpdir, "another_example.ini")
          with open(tmpfile, "w") as fobj:
              fobj.write("[DATA]\n")
              fobj.write("path = %s\n" % "/path/two")
          assert get_data_path() == tst_list + ["/path/two"] + old_pth
  
file_path: nibabel/nibabel/tests/test_data.py
imports: import os
  import sys
  import tempfile
  from os import environ
  from os.path import join
  from tempfile import TemporaryDirectory
  import pytest
  from ..None import data
  from ..data import Bomber, DataError, Datasource, VersionedDatasource, _cfg_value, datasource_or_bomber, find_data_dir, get_data_path, make_datasource
  from .test_environment import DATA_KEY, USER_KEY, with_environment
label_desc: Use image node_id 5 for calling a global function with example usage: test_data_path(with_nimd_env) without return types