code: def test_ensure_file(tmpdir):
      a = {"x": 1, "y": {"a": 1}}
      b = {"x": 123}
  
      source = os.path.join(str(tmpdir), "source.yaml")
      dest = os.path.join(str(tmpdir), "dest")
      destination = os.path.join(dest, "source.yaml")
  
      with open(source, "w") as f:
          yaml.dump(a, f)
  
      ensure_file(source=source, destination=dest, comment=False)
  
      with open(destination) as f:
          result = yaml.safe_load(f)
      assert result == a
  
      # don't overwrite old config files
      with open(source, "w") as f:
          yaml.dump(b, f)
  
      ensure_file(source=source, destination=dest, comment=False)
  
      with open(destination) as f:
          result = yaml.safe_load(f)
      assert result == a
  
      os.remove(destination)
  
      # Write again, now with comments
      ensure_file(source=source, destination=dest, comment=True)
  
      with open(destination) as f:
          text = f.read()
      assert "123" in text
  
      with open(destination) as f:
          result = yaml.safe_load(f)
      assert not result
  
imports: from __future__ import annotations
  import os
  import site
  import stat
  import sys
  from collections import OrderedDict
  from contextlib import contextmanager
  import pytest
  import yaml
  import dask.config
  from dask.config import _get_paths, canonical_name, collect, collect_env, collect_yaml, config, deserialize, ensure_file, expand_environment_variables, get, merge, pop, refresh, rename, serialize, update, update_defaults
  from dask.utils import tmpfile
label_desc: Use image node_id 19 for calling a global function with example usage: test_ensure_file(tmpdir) without return types