def test_remove_directory(self): """Test file_impl.remove_directory.""" os.mkdir('/dir') request = untrusted_runner_pb2.RemoveDirectoryRequest(path='/dir', recreate=False) response = file_impl.remove_directory(request, None) self.assertTrue(response.result) self.assertFalse(os.path.isdir('/dir')) os.mkdir('/dir') request = untrusted_runner_pb2.RemoveDirectoryRequest(path='/dir', recreate=True) response = file_impl.remove_directory(request, None) self.assertTrue(response.result) self.assertTrue(os.path.isdir('/dir'))
def remove_directory(path, recreate=False): """Remove a directory. If |recreate| is set, always creates the directory even if it did not exist.""" request = untrusted_runner_pb2.RemoveDirectoryRequest( path=path, recreate=recreate) response = host.stub().RemoveDirectory(request) return response.result