482
484
raise AssertionError('pattern "%s" not found in "%s"'
483
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))
485
493
def assertSubset(self, sublist, superlist):
486
494
"""Assert that every entry in sublist is present in superlist."""
719
727
encoding = bzrlib.user_encoding
720
728
return self.run_bzr(*args, **kwargs)[0].decode(encoding)
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.
742
bzr_path = os.path.dirname(os.path.dirname(bzrlib.__file__))+'/bzr'
744
process = Popen([sys.executable, bzr_path]+args, stdout=PIPE,
746
out = process.stdout.read()
747
err = process.stderr.read()
748
retcode = process.wait()
749
supplied_retcode = kwargs.get('retcode', 0)
750
if supplied_retcode is not None:
751
assert supplied_retcode == retcode
722
754
def check_inventory_shape(self, inv, shape):
723
755
"""Compare an inventory to a list of expected names.