コード例 #1
0
 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/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('/'))