示例#1
0
 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")))
示例#2
0
    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)
示例#3
0
 def tearDown(self):
     fsutil.remove_dir(self.temp_path())
示例#4
0
 def setUp(self):
     fsutil.remove_dir(self.temp_path())