code: def test_prefer_environment_over_user():
      with prefer_env:
          assert prefer_environment_over_user() is True
  
      with prefer_user:
          assert prefer_environment_over_user() is False
  
      # Test default if environment variable is not set, and try to determine if we are in a virtual environment
      os.environ.pop("JUPYTER_PREFER_ENV_PATH", None)
  
      # base prefix differs, venv
      with patch.object(sys, "base_prefix", "notthesame"):
          assert prefer_environment_over_user() == paths._do_i_own(
              sys.prefix
          )
  
      # conda
      with patch.object(sys, "base_prefix", sys.prefix):
          # in base env, don't prefer it
          with patch.dict(
              os.environ,
              {"CONDA_PREFIX": sys.prefix, "CONDA_DEFAULT_ENV": "base"},
          ):
              assert not prefer_environment_over_user()
          # in non-base env, prefer it
          with patch.dict(
              os.environ,
              {"CONDA_PREFIX": sys.prefix, "CONDA_DEFAULT_ENV": "/tmp"},
          ):
              assert prefer_environment_over_user() == paths._do_i_own(
                  sys.prefix
              )
  
          # conda env defined, but we aren't using it
          with patch.dict(
              os.environ,
              {
                  "CONDA_PREFIX": "/somewherelese",
                  "CONDA_DEFAULT_ENV": "/tmp",
              },
          ):
              assert not prefer_environment_over_user()
  
imports: from __future__ import annotations
  import os
  import re
  import shutil
  import site
  import stat
  import subprocess
  import sys
  import tempfile
  import warnings
  from unittest.mock import patch
  import pytest
  from platformdirs import __version_info__
  from jupyter_core import paths
  from jupyter_core.paths import UF_HIDDEN, _win32_restrict_file_to_user_ctypes, exists, is_file_hidden, is_hidden, issue_insecure_write_warning, jupyter_config_dir, jupyter_config_path, jupyter_data_dir, jupyter_path, jupyter_runtime_dir, prefer_environment_over_user, secure_write
label_desc: Use image node_id 38 for calling a global function with example usage: test_prefer_environment_over_user() without return types