import shutil import os import platform from common.file_config import FileConfig # 清除历史数据 def delete_file(*path): # 清除输入结果中的内容 for path in [*path]: all_log_files = os.listdir(path) all_log_files.sort() # 遍历 for num in range(len(all_log_files)): if os.path.basename(os.path.join(path,all_log_files[num])) != "__init__.py": try: os.remove(os.path.join(path,all_log_files[num])) except: shutil.rmtree(os.path.join(path,all_log_files[num])) # 清除上一次pytest运行缓存 if platform.system() == "Windows": cache_dir = os.path.join(FileConfig().base_dir + "\.pytest_cache") # Linux系统 else: cache_dir = os.path.join(FileConfig().base_dir + "/.pytest_cache") shutil.rmtree(cache_dir) if __name__ == "__main__": pass
时间: 2024-04-29 11:20:24 浏览: 123
你的代码看起来像是一个Python脚本,它导入了shutil、os和platform等模块,并从common.file_config中导入了FileConfig类。该脚本定义了一个名为delete_file的函数,该函数接受一个或多个路径参数,并删除指定路径中的所有文件和文件夹(除了名称为“__init__.py”的文件)。另外,该函数还会清除pytest运行缓存。最后,该脚本定义了一个名为“__main__”的条件语句,但这个条件语句没有任何内容,所以它实际上不会执行任何操作。
阅读全文
相关推荐














