summaryrefslogtreecommitdiff
path: root/fs/tests
diff options
context:
space:
mode:
authorwillmcgugan <willmcgugan@67cdc799-7952-0410-af00-57a81ceafa0f>2012-01-12 09:48:02 +0000
committerwillmcgugan <willmcgugan@67cdc799-7952-0410-af00-57a81ceafa0f>2012-01-12 09:48:02 +0000
commit315ea957d26996f84d3a453bf45386bcc839c4c1 (patch)
tree5510e0b8c6b52be7127ada3633082aaa4af40e37 /fs/tests
parent39ef2b6768f446470e6b6a53aab9ffe01e9fade1 (diff)
downloadpyfilesystem-git-315ea957d26996f84d3a453bf45386bcc839c4c1.tar.gz
Added a remove_all function to utils
Diffstat (limited to 'fs/tests')
-rw-r--r--fs/tests/test_utils.py31
1 files changed, 19 insertions, 12 deletions
diff --git a/fs/tests/test_utils.py b/fs/tests/test_utils.py
index b634029..4653a71 100644
--- a/fs/tests/test_utils.py
+++ b/fs/tests/test_utils.py
@@ -87,20 +87,27 @@ class TestUtils(unittest.TestCase):
utils.movedir((fs1, "from"), fs2)
self.assert_(not fs1.exists("from"))
self._check_fs(fs2)
-
-if __name__ == "__main__":
-
- def _make_fs(fs):
+
+ def test_remove_all(self):
+ """Test remove_all function"""
+ fs = TempFS()
fs.setcontents("f1", "file 1")
fs.setcontents("f2", "file 2")
fs.setcontents("f3", "file 3")
fs.makedir("foo/bar", recursive=True)
- fs.setcontents("foo/bar/fruit", "apple")
+ fs.setcontents("foo/bar/fruit", "apple")
+ fs.setcontents("foo/baz", "baz")
+
+ utils.remove_all(fs, "foo/bar")
+ self.assert_(not fs.exists("foo/bar/fruit"))
+ self.assert_(fs.exists("foo/bar"))
+ self.assert_(fs.exists("foo/baz"))
+ utils.remove_all(fs, "")
+ self.assert_(not fs.exists("foo/bar/fruit"))
+ self.assert_(not fs.exists("foo/bar/baz"))
+ self.assert_(not fs.exists("foo/baz"))
+ self.assert_(not fs.exists("foo"))
+ self.assert_(not fs.exists("f1"))
+ self.assert_(fs.isdirempty('/'))
- fs1 = TempFS()
- fs2 = TempFS()
- fs1sub = fs1.makeopendir("from")
- _make_fs(fs1sub)
- utils.movedir((fs1, "from"), fs2)
- #self.assert_(not fs1.exists("from"))
- #self._check_fs(fs2) \ No newline at end of file
+ \ No newline at end of file