721
721
encoding = bzrlib.user_encoding
722
722
return self.run_bzr(*args, **kwargs)[0].decode(encoding)
724
def run_bzr_external(self, *args, **kwargs):
724
def run_bzr_subprocess(self, *args, **kwargs):
725
"""Run bzr in a subprocess for testing.
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.
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,
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
738
745
return [out, err]
740
747
def check_inventory_shape(self, inv, shape):