code: def override_temp(replacement):
      
      pkg_resources.py31compat.makedirs(replacement, exist_ok=True)
  
      saved = tempfile.tempdir
  
      tempfile.tempdir = replacement
  
      try:
          yield
      finally:
          tempfile.tempdir = saved
docs: Monkey-patch tempfile.tempdir with replacement, ensuring it exists