code: def cached_url(f, url=None, keys=None):
      """Test decorator providing a URL to clone from, pointing to cached dataset
  
      If config datalad.tests.cache is not set, delivers the original `url`,
      otherwise a file-scheme url to the cached clone thereof.
  
      Notes
      -----
  
      While this is similar to `cached_dataset`, there are important differences.
  
      1. As we deliver an URL, `version` parameter is irrelevant. The only
         relevant notion of version would need to be included in the URL
  
      2. We cannot request particular paths to be present in cache, since we
         a version to refer to by those paths. Therefore keys need to be
         specified.
  
      Parameters
      ----------
      url: str
          URL to the original dataset
      keys: str or list or None
          (list of) annex keys to get content for.
  
      Returns
      -------
      str
          URL to the cached dataset or the original URL if caching was disabled
      """
  
      # TODO: See Notes 1.)
      #       Append fragments/parameters of `url` to what we return -
      #       depending on how we generally decide to address versioned
      #       URLs for clone etc.
  
      @better_wraps(f)
      def _wrap_cached_url(*arg, **kw):
          if DATALAD_TESTS_CACHE:
              ds = get_cached_dataset(url, version=None)
              if keys:
                  ds.repo.get(keys, key=True)
              new_url = ds.pathobj.as_uri()
          else:
              new_url = url
  
          return f(*(arg + (new_url,)), **kw)
  
      return _wrap_cached_url
  
file_path: datalad/datalad/tests/utils_cached_dataset.py
imports: from datalad import cfg
  from datalad.core.distributed.clone import Clone
  from datalad.distribution.dataset import Dataset
  from datalad.support.annexrepo import AnnexRepo
  from datalad.tests.utils_pytest import DEFAULT_REMOTE, with_tempfile
  from datalad.utils import Path, better_wraps, ensure_list, optional_args, rmtree
label_desc: Use image node_id 4 for calling a global function with example usage: cached_url(f, url, keys) and returns: _wrap_cached_url, f