~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Aaron Bentley
  • Date: 2006-06-11 21:26:20 UTC
  • mto: This revision was merged to the branch mainline in revision 1764.
  • Revision ID: aaron.bentley@utoronto.ca-20060611212620-2517ff1406176fd9
Rename run_bzr_external -> run_bzr_subprocess, add docstring

Show diffs side-by-side

added added

removed removed

Lines of Context:
721
721
            encoding = bzrlib.user_encoding
722
722
        return self.run_bzr(*args, **kwargs)[0].decode(encoding)
723
723
 
724
 
    def run_bzr_external(self, *args, **kwargs):
 
724
    def run_bzr_subprocess(self, *args, **kwargs):
 
725
        """Run bzr in a subprocess for testing.
 
726
 
 
727
        This starts a new Python interpreter and runs bzr in there. 
 
728
        This should only be used for tests that have a justifiable need for
 
729
        this isolation: e.g. they are testing startup time, or signal
 
730
        handling, or early startup code, etc.  Subprocess code can't be 
 
731
        profiled or debugged so easily.
 
732
        """
725
733
        bzr_path = os.path.dirname(os.path.dirname(bzrlib.__file__))+'/bzr'
726
734
        if len(args) == 1:
727
735
            args = shlex.split(args[0])
728
736
        args = list(args)
729
 
        process = Popen([bzr_path]+args, stdout=PIPE, stderr=PIPE)
 
737
        process = Popen([sys.executable, bzr_path]+args, stdout=PIPE, 
 
738
                         stderr=PIPE)
730
739
        out = process.stdout.read()
731
740
        err = process.stderr.read()
732
741
        retcode = process.wait()
733
 
        supplied_retcode = kwargs.get('retcode')
 
742
        supplied_retcode = kwargs.get('retcode', 0)
734
743
        if supplied_retcode is not None:
735
744
            assert supplied_retcode == retcode
736
 
        else:
737
 
            assert retcode == 0
738
745
        return [out, err]
739
746
 
740
747
    def check_inventory_shape(self, inv, shape):