Commit 539f4be6 by willmcgugan

More work on the test suite

parent 7973da6a
...@@ -400,6 +400,18 @@ class FS(object): ...@@ -400,6 +400,18 @@ class FS(object):
def getsize(self, path): def getsize(self, path):
return self.getinfo(path)['size'] return self.getinfo(path)['size']
def makefile(self, path, data):
f = None
try:
f = self.open(path, "wb")
f.write(data)
finally:
if f is not None:
f.close()
return True
class SubFS(FS): class SubFS(FS):
......
...@@ -142,7 +142,7 @@ if __name__ == "__main__": ...@@ -142,7 +142,7 @@ if __name__ == "__main__":
osfs = OSFS("~/projects") osfs = OSFS("~/projects")
print osfs print osfs
for filename in osfs.walk_files("/", "*.pov"): for filename in osfs.walkfiles("/", "*.pov"):
print filename print filename
print osfs.getinfo(filename) print osfs.getinfo(filename)
......
...@@ -137,6 +137,7 @@ class TestFS(unittest.TestCase): ...@@ -137,6 +137,7 @@ class TestFS(unittest.TestCase):
def test_removedir(self): def test_removedir(self):
check = self.check check = self.check
self.fs.makedir("a") self.fs.makedir("a")
self.assert_(check("a")) self.assert_(check("a"))
...@@ -157,6 +158,21 @@ class TestFS(unittest.TestCase): ...@@ -157,6 +158,21 @@ class TestFS(unittest.TestCase):
self.assert_(not check("foo/bar")) self.assert_(not check("foo/bar"))
self.assert_(not check("foo")) self.assert_(not check("foo"))
def test_rename(self):
check = self.check
self.fs.open("foo.txt", 'wt').write("Hello, World!")
self.assert_(check("foo.txt"))
self.fs.rename("foo.txt", "bar.txt")
self.assert_(check("bar.txt"))
def test_makefile(self):
check = self.check
self.fs.makefile("foo.txt", "Hello, World!")
data = self.fs.open("foo.txt").read()
self.assertEqual(data, "Hello, World!")
if __name__ == "__main__": if __name__ == "__main__":
#t = TestFS() #t = TestFS()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment