code: def test_link_file_load(tempfile=None):
      tempfile2 = tempfile + "_"
  
      with open(tempfile, "w") as f:
          f.write("LOAD")
  
      link_file_load(tempfile, tempfile2)  # this should work in general
  
      ok_(os.path.exists(tempfile2))
  
      with open(tempfile2, "r") as f:
          assert_equal(f.read(), "LOAD")
  
      def inode(fname):
          with open(fname) as fd:
              return os.fstat(fd.fileno()).st_ino
  
      def stats(fname, times=True):
          """Return stats on the file which should have been preserved"""
          with open(fname) as fd:
              st = os.fstat(fd.fileno())
              stats = (st.st_mode, st.st_uid, st.st_gid, st.st_size)
              if times:
                  return stats + (st.st_atime, st.st_mtime)
              else:
                  return stats
              # despite copystat mtime is not copied. TODO
              #        st.st_mtime)
  
      # TODO: fix up the test to not rely on OS assumptions but rather
      # first sense filesystem about linking support.
      # For Yarik's Windows 10 VM test was failing under assumption that
      # linking is not supported at all, but I guess it does.
      if True:  # on_linux or on_osx:
          # above call should result in the hardlink
          assert_equal(inode(tempfile), inode(tempfile2))
          assert_equal(stats(tempfile), stats(tempfile2))
  
          # and if we mock absence of .link
          def raise_AttributeError(*args):
              raise AttributeError("TEST")
  
          with patch("os.link", raise_AttributeError):
              with swallow_logs(logging.WARNING) as cm:
                  link_file_load(
                      tempfile, tempfile2
                  )  # should still work
                  ok_("failed (TEST), copying file" in cm.out)
  
          # should be a copy (after mocked call)
          assert_not_equal(inode(tempfile), inode(tempfile2))
      with open(tempfile2, "r") as f:
          assert_equal(f.read(), "LOAD")
      assert_equal(
          stats(tempfile, times=False), stats(tempfile2, times=False)
      )
      unlink(tempfile2)
  
imports: import glob
  import logging
  import os
  import os.path
  import sys
  from time import sleep
  from unittest.mock import patch
  from datalad.api import Dataset
  from datalad.cmd import GitWitlessRunner, KillOutput, StdOutErrCapture, WitlessRunner
  from datalad.support.exceptions import CommandError
  from ...consts import ARCHIVES_SPECIAL_REMOTE
  from ...support.annexrepo import AnnexRepo
  from ...tests.test_archives import fn_archive_obscure, fn_archive_obscure_ext, fn_in_archive_obscure
  from ...tests.utils_pytest import abspath, assert_equal, assert_false, assert_not_equal, assert_not_in, assert_raises, assert_true, chpwd, eq_, in_, known_failure_githubci_win, ok_, serve_path_via_http, swallow_logs, with_tempfile, with_tree
  from ...utils import unlink
  from ..archives import ArchiveAnnexCustomRemote, link_file_load
label_desc: Use image node_id 6 for calling a global function with example usage: test_link_file_load(tempfile) and returns: os, unknown, stats