484
484
raise AssertionError('pattern "%s" not found in "%s"'
485
485
% (needle_re, haystack))
487
def assertNotContainsRe(self, haystack, needle_re):
488
"""Assert that a does not match a regular expression"""
489
if re.search(needle_re, haystack):
490
raise AssertionError('pattern "%s" found in "%s"'
491
% (needle_re, haystack))
487
493
def assertSubset(self, sublist, superlist):
488
494
"""Assert that every entry in sublist is present in superlist."""
721
727
encoding = bzrlib.user_encoding
722
728
return self.run_bzr(*args, **kwargs)[0].decode(encoding)
724
def run_bzr_external(self, *args, **kwargs):
730
def run_bzr_subprocess(self, *args, **kwargs):
731
"""Run bzr in a subprocess for testing.
733
This starts a new Python interpreter and runs bzr in there.
734
This should only be used for tests that have a justifiable need for
735
this isolation: e.g. they are testing startup time, or signal
736
handling, or early startup code, etc. Subprocess code can't be
737
profiled or debugged so easily.
739
:param retcode: The status code that is expected. Defaults to 0. If
740
None is supplied, the status code is not checked.
725
742
bzr_path = os.path.dirname(os.path.dirname(bzrlib.__file__))+'/bzr'
727
args = shlex.split(args[0])
728
743
args = list(args)
729
process = Popen([bzr_path]+args, stdout=PIPE, stderr=PIPE)
744
process = Popen([sys.executable, bzr_path]+args, stdout=PIPE,
730
746
out = process.stdout.read()
731
747
err = process.stderr.read()
732
748
retcode = process.wait()
733
supplied_retcode = kwargs.get('retcode')
749
supplied_retcode = kwargs.get('retcode', 0)
734
750
if supplied_retcode is not None:
735
751
assert supplied_retcode == retcode
738
752
return [out, err]
740
754
def check_inventory_shape(self, inv, shape):