code: def download_to_temp(tmp_path_factory):
      """
      Context manager which defaults the "data_dir" to a temporary directory
      which is automatically cleaned up on exit.
  
      """
      with contextlib.ExitStack() as stack:
          stack.callback(
              cartopy.config.__setitem__,
              "downloaders",
              cartopy.config["downloaders"].copy(),
          )
          stack.callback(
              cartopy.config.__setitem__,
              "data_dir",
              cartopy.config["data_dir"],
          )
  
          tmp_dir = tmp_path_factory.mktemp("cartopy_data")
          cartopy.config["data_dir"] = str(tmp_dir)
  
          yield tmp_dir
  
file_path: cartopy/lib/cartopy/tests/io/test_downloaders.py
imports: import contextlib
  from pathlib import Path
  from unittest import mock
  import pytest
  import cartopy
  import cartopy.io
  from cartopy.io.shapereader import NEShpDownloader
label_desc: Use image node_id 3 for calling a global function with example usage: download_to_temp(tmp_path_factory) without return types