code: def begin(self):
          
          # The calls to begin/finalize end up like this: a call to begin() on
          # instance A of the plugin, then a paired begin/finalize for each test
          # on instance B, then a final call to finalize() on instance A.
  
          # TODO: Do only if isatty.
          self._stderr.append(sys.stderr)
          sys.stderr = StreamWrapper(sys.stderr, self)  # TODO: Any point?
  
          self._stdout.append(sys.stdout)
          sys.stdout = StreamWrapper(sys.stdout, self)
  
          self._set_trace.append(pdb.set_trace)
          pdb.set_trace = set_trace
  
          self._cmdloop.append(pdb.Pdb.cmdloop)
          pdb.Pdb.cmdloop = cmdloop
  
          # nosetests changes directories to the tests dir when run from a
          # distribution dir, so save the original cwd for relativizing paths.
          self._cwd = '' if self.conf.options.absolute_paths else getcwd()
docs: Make some monkeypatches to dodge progress bar.
  
          Wrap stderr and stdout to keep other users of them from smearing the
          progress bar. Wrap some pdb routines to stop showing the bar while in
          the debugger.