Merge "Add in memory filesystem clearing"
This commit is contained in:
@@ -141,6 +141,10 @@ class FakeFilesystem(object):
|
||||
paths.append(child_path)
|
||||
return paths
|
||||
|
||||
def clear(self):
|
||||
for node in list(self._root.reverse_iter()):
|
||||
node.disassociate()
|
||||
|
||||
def _iter_pieces(self, path, include_root=False):
|
||||
if path == self._root.item:
|
||||
# Check for this directly as the following doesn't work with
|
||||
|
||||
@@ -113,6 +113,17 @@ class MemoryFilesystemTest(test.TestCase):
|
||||
path += "/" + p
|
||||
self.assertIsNone(fs[path])
|
||||
|
||||
def test_clear(self):
|
||||
fs = impl_memory.FakeFilesystem()
|
||||
paths = ['/b', '/c', '/a/b/c']
|
||||
for p in paths:
|
||||
fs.ensure_path(p)
|
||||
for p in paths:
|
||||
self.assertIsNone(self._get_item_path(fs, p))
|
||||
fs.clear()
|
||||
for p in paths:
|
||||
self.assertRaises(exc.NotFound, self._get_item_path, fs, p)
|
||||
|
||||
def test_not_found(self):
|
||||
fs = impl_memory.FakeFilesystem()
|
||||
self.assertRaises(exc.NotFound, self._get_item_path, fs, '/c')
|
||||
|
||||
Reference in New Issue
Block a user