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.
  :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
class_docstr_tok: ["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",".",":","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 creates a temporary directory and
  changes the current working directory to it. This isolates tests
  that affect the contents of the CWD to prevent them from
  interfering with each other.
  
  :param temp_dir: Create the temporary directory under this
      directory. If given, the created directory is not removed
      when exiting.
  
  .. versionchanged:: 8.0
      Added the ``temp_dir`` parameter.
code: def isolated_filesystem(
      self,
      temp_dir: t.Optional[t.Union[str, "os.PathLike[str]"]] = None,
  ) -> t.Iterator[str]:
      """A context manager that creates a temporary directory and
      changes the current working directory to it. This isolates tests
      that affect the contents of the CWD to prevent them from
      interfering with each other.
  
      :param temp_dir: Create the temporary directory under this
          directory. If given, the created directory is not removed
          when exiting.
  
      .. versionchanged:: 8.0
          Added the ``temp_dir`` parameter.
      """
      cwd = os.getcwd()
      dt = tempfile.mkdtemp(dir=temp_dir)
      os.chdir(dt)
  
      try:
          yield dt
      finally:
          os.chdir(cwd)
  
          if temp_dir is None:
              try:
                  shutil.rmtree(dt)
              except OSError:  # noqa: B014
                  pass
  
imports: import contextlib
  import io
  import os
  import shlex
  import shutil
  import sys
  import tempfile
  import typing
  from types import TracebackType
  from .None import formatting
  from .None import termui
  from .None import utils
  from ._compat import _find_binary_reader
label_desc: Use image node_id 6 for calling the CliRunner obj's underlying member method code with example usage: obj.isolated_filesystem(temp_dir) without return types