code: def make_env_restorer():
      """Snapshot the current environment, return a function to restore that.
  
      This is intended to produce cleanup functions for tests. For example,
      using the :class:`unittest.TestCase` API::
  
          def setUp(self):
              self.addCleanup(testpath.make_env_restorer())
  
      Any changes a test makes to the environment variables will be wiped out
      before the next test is run.
      """
      orig_env = os.environ.copy()
  
      def restore():
          os.environ.clear()
          os.environ.update(orig_env)
  
      return restore
  
imports: import contextlib
  import os
label_desc: Use image node_id 3 for calling a global function with example usage: make_env_restorer() and returns: restore