def testCrossMountMoveTo(self):
"""
"""
# Bit of a whitebox test - force os.rename, which moveTo tries
# before falling back to a slower method, to fail, forcing moveTo to
# use the slower behavior.
invokedWith = []
def faultyRename(src, dest):
invokedWith.append((src, dest))
if len(invokedWith) == 2:
raise OSError(errno.EXDEV, 'Test-induced failure simulating cross-device rename failure')
return originalRename(src, dest)
originalRename = os.rename
os.rename = faultyRename
try:
self.testMoveTo()
# A bit of a sanity check for this whitebox test - if our rename
# was never invoked, the test has probably fallen into
# disrepair!
self.failUnless(len(invokedWith) >= 2)
finally:
os.rename = originalRename
评论列表
文章目录