1000
1000
for key, (parent, name) in known_hooks.iter_parent_objects():
1001
1001
current_hooks = getattr(parent, name)
1002
1002
self._preserved_hooks[parent] = (name, current_hooks)
1003
self._preserved_lazy_hooks = hooks._lazy_hooks
1004
hooks._lazy_hooks = {}
1003
1005
self.addCleanup(self._restoreHooks)
1004
1006
for key, (parent, name) in known_hooks.iter_parent_objects():
1005
1007
factory = known_hooks.get(key)
1265
1267
'st_mtime did not match')
1266
1268
self.assertEqual(expected.st_ctime, actual.st_ctime,
1267
1269
'st_ctime did not match')
1268
if sys.platform != 'win32':
1270
if sys.platform == 'win32':
1269
1271
# On Win32 both 'dev' and 'ino' cannot be trusted. In python2.4 it
1270
1272
# is 'dev' that varies, in python 2.5 (6?) it is st_ino that is
1271
# odd. Regardless we shouldn't actually try to assert anything
1272
# about their values
1273
# odd. We just force it to always be 0 to avoid any problems.
1274
self.assertEqual(0, expected.st_dev)
1275
self.assertEqual(0, actual.st_dev)
1276
self.assertEqual(0, expected.st_ino)
1277
self.assertEqual(0, actual.st_ino)
1273
1279
self.assertEqual(expected.st_dev, actual.st_dev,
1274
1280
'st_dev did not match')
1275
1281
self.assertEqual(expected.st_ino, actual.st_ino,
1439
1445
def assertFileEqual(self, content, path):
1440
1446
"""Fail if path does not contain 'content'."""
1441
self.failUnlessExists(path)
1447
self.assertPathExists(path)
1442
1448
f = file(path, 'rb')
1455
1461
self.assertEqual(expected_docstring, obj.__doc__)
1463
@symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((2, 4)))
1457
1464
def failUnlessExists(self, path):
1465
return self.assertPathExists(path)
1467
def assertPathExists(self, path):
1458
1468
"""Fail unless path or paths, which may be abs or relative, exist."""
1459
1469
if not isinstance(path, basestring):
1461
self.failUnlessExists(p)
1471
self.assertPathExists(p)
1463
self.failUnless(osutils.lexists(path),path+" does not exist")
1473
self.assertTrue(osutils.lexists(path),
1474
path + " does not exist")
1476
@symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((2, 4)))
1465
1477
def failIfExists(self, path):
1478
return self.assertPathDoesNotExist(path)
1480
def assertPathDoesNotExist(self, path):
1466
1481
"""Fail if path or paths, which may be abs or relative, exist."""
1467
1482
if not isinstance(path, basestring):
1469
self.failIfExists(p)
1484
self.assertPathDoesNotExist(p)
1471
self.failIf(osutils.lexists(path),path+" exists")
1486
self.assertFalse(osutils.lexists(path),
1473
1489
def _capture_deprecation_warnings(self, a_callable, *args, **kwargs):
1474
1490
"""A helper for callDeprecated and applyDeprecated.
1657
1673
def _restoreHooks(self):
1658
1674
for klass, (name, hooks) in self._preserved_hooks.items():
1659
1675
setattr(klass, name, hooks)
1676
hooks._lazy_hooks = self._preserved_lazy_hooks
1661
1678
def knownFailure(self, reason):
1662
1679
"""This test has failed for some known reason."""
2108
2125
% (process_args, retcode, process.returncode))
2109
2126
return [out, err]
2111
def check_inventory_shape(self, inv, shape):
2112
"""Compare an inventory to a list of expected names.
2128
def check_tree_shape(self, tree, shape):
2129
"""Compare a tree to a list of expected names.
2114
2131
Fail if they are not precisely equal.
2117
2134
shape = list(shape) # copy
2118
for path, ie in inv.entries():
2135
for path, ie in tree.iter_entries_by_dir():
2119
2136
name = path.replace('\\', '/')
2120
2137
if ie.kind == 'directory':
2121
2138
name = name + '/'
2140
pass # ignore root entry
2123
2142
shape.remove(name)
2125
2144
extras.append(name)