1295
1295
self.log('errors:\n%r', err)
1296
1296
if retcode is not None:
1297
self.assertEquals(retcode, result)
1297
self.assertEquals(retcode, result,
1298
message='Unexpected return code')
1298
1299
return out, err
1300
1301
def run_bzr(self, *args, **kwargs):
1315
1316
encoding = kwargs.pop('encoding', None)
1316
1317
stdin = kwargs.pop('stdin', None)
1317
1318
working_dir = kwargs.pop('working_dir', None)
1318
return self.run_bzr_captured(args, retcode=retcode, encoding=encoding,
1319
stdin=stdin, working_dir=working_dir)
1319
error_regexes = kwargs.pop('error_regexes', [])
1321
out, err = self.run_bzr_captured(args, retcode=retcode,
1322
encoding=encoding, stdin=stdin, working_dir=working_dir)
1324
for regex in error_regexes:
1325
self.assertContainsRe(err, regex)
1321
1329
def run_bzr_decode(self, *args, **kwargs):
1322
1330
if 'encoding' in kwargs:
1349
1357
'commit', '--strict', '-m', 'my commit comment')
1351
1359
kwargs.setdefault('retcode', 3)
1352
out, err = self.run_bzr(*args, **kwargs)
1353
for regex in error_regexes:
1354
self.assertContainsRe(err, regex)
1360
out, err = self.run_bzr(error_regexes=error_regexes, *args, **kwargs)
1355
1361
return out, err
1357
1363
def run_bzr_subprocess(self, *args, **kwargs):
1953
1959
self.assertEqualDiff(content, s)
1955
1961
def failUnlessExists(self, path):
1956
"""Fail unless path, which may be abs or relative, exists."""
1957
self.failUnless(osutils.lexists(path),path+" does not exist")
1962
"""Fail unless path or paths, which may be abs or relative, exist."""
1963
if not isinstance(path, basestring):
1965
self.failUnlessExists(p)
1967
self.failUnless(osutils.lexists(path),path+" does not exist")
1959
1969
def failIfExists(self, path):
1960
"""Fail if path, which may be abs or relative, exists."""
1961
self.failIf(osutils.lexists(path),path+" exists")
1970
"""Fail if path or paths, which may be abs or relative, exist."""
1971
if not isinstance(path, basestring):
1973
self.failIfExists(p)
1975
self.failIf(osutils.lexists(path),path+" exists")
1977
def assertInWorkingTree(self,path,root_path='.',tree=None):
1978
"""Assert whether path or paths are in the WorkingTree"""
1980
tree = workingtree.WorkingTree.open(root_path)
1981
if not isinstance(path, basestring):
1983
self.assertInWorkingTree(p,tree=tree)
1985
self.assertIsNot(tree.path2id(path), None,
1986
path+' not in working tree.')
1988
def assertNotInWorkingTree(self,path,root_path='.',tree=None):
1989
"""Assert whether path or paths are not in the WorkingTree"""
1991
tree = workingtree.WorkingTree.open(root_path)
1992
if not isinstance(path, basestring):
1994
self.assertNotInWorkingTree(p,tree=tree)
1996
self.assertIs(tree.path2id(path), None, path+' in working tree.')
1964
1999
class TestCaseWithTransport(TestCaseInTempDir):