def test_remove_dir(self): fsutil.create_file(self.temp_path("a/b/c/d.txt")) fsutil.create_file(self.temp_path("a/b/c/e.txt")) fsutil.create_file(self.temp_path("a/b/c/f.txt")) removed = fsutil.remove_dir(self.temp_path("a/c/")) self.assertFalse(removed) removed = fsutil.remove_dir(self.temp_path("a/b/")) self.assertTrue(removed) self.assertTrue(fsutil.exists(self.temp_path("a"))) self.assertFalse(fsutil.exists(self.temp_path("a/b")))
def delete(self, request, absolute_path=''): if not absolute_path: raise ParseError absolute_path = self.atob(absolute_path) node = Node.parse(relative=absolute_path) if not node.is_exist: raise ParseError('Item is not existed.') if node.is_dir: fsutil.remove_dir(node.absolute) else: fsutil.remove_file(node.absolute) return Response(data=True)
def tearDown(self): fsutil.remove_dir(self.temp_path())
def setUp(self): fsutil.remove_dir(self.temp_path())