class_docstr: The CLI runner provides functionality to invoke a Click command line
  script for unittesting purposes in a isolated environment.  This only
  works in single-threaded systems without any concurrency as it changes the
  global interpreter state.
  
  :param charset: the character set for the input and output data.  This is
                  UTF-8 by default and should not be changed currently as
                  the reporting to Click only works in Python 2 properly.
  :param env: a dictionary with environment variables for overriding.
  :param echo_stdin: if this is set to `True`, then reading from stdin writes
                     to stdout.  This is useful for showing examples in
                     some circumstances.  Note that regular prompts
                     will automatically echo the input.
  :param mix_stderr: if this is set to `False`, then stdout and stderr are
                     preserved as independent streams.  This is useful for
                     Unix-philosophy apps that have predictable stdout and
                     noisy stderr, such that each may be measured
                     independently
docstr: A context manager that sets up the isolation for invoking of a
  command line tool.  This sets up stdin with the given input data
  and `os.environ` with the overrides from the given dictionary.
  This also rebinds some internals in Click to be mocked (like the
  prompt functionality).
  
  This is automatically done in the :meth:`invoke` method.
  
  .. versionadded:: 4.0
     The ``color`` parameter was added.
  
  :param input: the input stream to put into sys.stdin.
  :param env: the environment overrides as dictionary.
  :param color: whether the output should contain color codes. The
                application can still override this explicitly.
code: def isolation(self, input=None, env=None, color=False):
      """A context manager that sets up the isolation for invoking of a
      command line tool.  This sets up stdin with the given input data
      and `os.environ` with the overrides from the given dictionary.
      This also rebinds some internals in Click to be mocked (like the
      prompt functionality).
  
      This is automatically done in the :meth:`invoke` method.
  
      .. versionadded:: 4.0
         The ``color`` parameter was added.
  
      :param input: the input stream to put into sys.stdin.
      :param env: the environment overrides as dictionary.
      :param color: whether the output should contain color codes. The
                    application can still override this explicitly.
      """
      input = make_input_stream(input, self.charset)
  
      old_stdin = sys.stdin
      old_stdout = sys.stdout
      old_stderr = sys.stderr
      old_forced_width = formatting.FORCED_WIDTH
      formatting.FORCED_WIDTH = 80
  
      env = self.make_env(env)
  
      if PY2:
          bytes_output = StringIO()
          if self.echo_stdin:
              input = EchoingStdin(input, bytes_output)
          sys.stdout = bytes_output
          if not self.mix_stderr:
              bytes_error = StringIO()
              sys.stderr = bytes_error
      else:
          bytes_output = io.BytesIO()
          if self.echo_stdin:
              input = EchoingStdin(input, bytes_output)
          input = io.TextIOWrapper(input, encoding=self.charset)
          sys.stdout = io.TextIOWrapper(
              bytes_output, encoding=self.charset
          )
          if not self.mix_stderr:
              bytes_error = io.BytesIO()
              sys.stderr = io.TextIOWrapper(
                  bytes_error, encoding=self.charset
              )
  
      if self.mix_stderr:
          sys.stderr = sys.stdout
  
      sys.stdin = input
  
      def visible_input(prompt=None):
          sys.stdout.write(prompt or "")
          val = input.readline().rstrip("\r\n")
          sys.stdout.write("{}\n".format(val))
          sys.stdout.flush()
          return val
  
      def hidden_input(prompt=None):
          sys.stdout.write("{}\n".format(prompt or ""))
          sys.stdout.flush()
          return input.readline().rstrip("\r\n")
  
      def _getchar(echo):
          char = sys.stdin.read(1)
          if echo:
              sys.stdout.write(char)
              sys.stdout.flush()
          return char
  
      default_color = color
  
      def should_strip_ansi(stream=None, color=None):
          if color is None:
              return not default_color
          return not color
  
      old_visible_prompt_func = termui.visible_prompt_func
      old_hidden_prompt_func = termui.hidden_prompt_func
      old__getchar_func = termui._getchar
      old_should_strip_ansi = utils.should_strip_ansi
      termui.visible_prompt_func = visible_input
      termui.hidden_prompt_func = hidden_input
      termui._getchar = _getchar
      utils.should_strip_ansi = should_strip_ansi
  
      old_env = {}
      try:
          for key, value in iteritems(env):
              old_env[key] = os.environ.get(key)
              if value is None:
                  try:
                      del os.environ[key]
                  except Exception:
                      pass
              else:
                  os.environ[key] = value
          yield (bytes_output, not self.mix_stderr and bytes_error)
      finally:
          for key, value in iteritems(old_env):
              if value is None:
                  try:
                      del os.environ[key]
                  except Exception:
                      pass
              else:
                  os.environ[key] = value
          sys.stdout = old_stdout
          sys.stderr = old_stderr
          sys.stdin = old_stdin
          termui.visible_prompt_func = old_visible_prompt_func
          termui.hidden_prompt_func = old_hidden_prompt_func
          termui._getchar = old__getchar_func
          utils.should_strip_ansi = old_should_strip_ansi
          formatting.FORCED_WIDTH = old_forced_width
  
imports: import contextlib
  import os
  import shlex
  import shutil
  import sys
  import tempfile
  from .None import formatting
  from .None import termui
  from .None import utils
  from ._compat import iteritems
  from ._compat import PY2
  from ._compat import string_types
label_desc: Use image node_id 4 for calling the CliRunner obj's underlying member method code with example usage: obj.isolation(input, env, color) and returns: val, input, char, unknown, unknown