code: def test_stage_cache(tmp_dir, dvc, mocker):
      tmp_dir.gen("dep", "dep")
      tmp_dir.gen(
          "script.py",
          'open("out", "w+").write("out"); ',
      )
      stage = dvc.run(
          cmd="python script.py",
          deps=["script.py", "dep"],
          outs=["out"],
          name="write-out",
      )
  
      with dvc.lock:
          stage.remove(remove_outs=True, force=True)
  
      assert not (tmp_dir / "out").exists()
      assert not (tmp_dir / "dvc.yaml").exists()
      assert not (tmp_dir / "dvc.lock").exists()
  
      cache_dir = os.path.join(
          dvc.stage_cache.cache_dir,
          "c7",
          "c7a85d71de1912c43d9c5b6218c71630d6277e8fc11e4ccf5e12b3c202234838",
      )
      cache_file = os.path.join(
          cache_dir,
          "5e2824029f8da9ef6c57131a638ceb65f27c02f16c85d71e85671c27daed0501",
      )
  
      assert os.path.isdir(cache_dir)
      assert os.listdir(cache_dir) == [os.path.basename(cache_file)]
      assert os.path.isfile(cache_file)
  
      run_spy = mocker.patch("dvc.stage.run.cmd_run")
      checkout_spy = mocker.spy(dvc_output, "checkout")
      with dvc.lock:
          stage.run()
  
      assert not run_spy.called
      assert checkout_spy.call_count == 2
  
      assert (tmp_dir / "out").exists()
      assert (tmp_dir / "out").read_text() == "out"
  
file_path: dvc/tests/unit/stage/test_cache.py
imports: import os
  import pytest
  import dvc.output
label_desc: Use image node_id 1 for calling a global function with example usage: test_stage_cache(tmp_dir, dvc, mocker) without return types