code: def test_user_dir(with_environment):
      if USER_KEY in env:
          del env[USER_KEY]
      home_dir = nibe.get_home_dir()
      if os.name == "posix":
          exp = pjoin(home_dir, ".nipy")
      else:
          exp = pjoin(home_dir, "_nipy")
      assert exp == nibe.get_nipy_user_dir()
      env[USER_KEY] = "/a/path"
      assert abspath("/a/path") == nibe.get_nipy_user_dir()
  
file_path: nibabel/nibabel/tests/test_environment.py
imports: import os
  from os import environ
  from os.path import abspath
  from os.path import join
  import pytest
  from ..None import environment
label_desc: Use image node_id 3 for calling a global function with example usage: test_user_dir(with_environment) without return types