def __del__(self): """删除不存在的module""" module = list(self.all_param.keys()) package = self._get_package() [package.remove(modules) for modules in module if modules in package] path = [PATH('.') + '/' + self.file_path + '/' + package_path for package_path in package] [shutil.rmtree(remove) for remove in path] # 不管目录是否为空,都将目录删除
def _get_package(self): """ 获取包名 :return 包名以列表形式返回 """ path = PATH('.') + '/' + self.file_path package = [name for name in os.listdir(path) if '.' not in name ][:-1] return package
def _project_check(self): """用于判断项目目录是否存在,不存在重新创建,项目并生成对应的py""" project_path = PATH('.') + '\\' + self.file_path if not os.path.exists(project_path): os.makedirs(project_path) with open(project_path + '\\' + self.common_py, 'wt', encoding=self.encoding) as f: f.write(PROJECT_COMMON) with open(project_path + '\\' + self.common_ya, 'wt', encoding=self.encoding): with open(project_path + '\\' + self.init, 'wt', encoding=self.encoding): pass
import unittest import time import os import traceback from config_path.path_file import PATH from model.MyUnitTest import UnitTests from model.SkipModule import Skip, current_module from Manufacture.marketing_contact.currency import MarketingContactElement _SKIP = Skip(current_module(PATH(__file__))).is_skip _SKIP_REASON = Skip(current_module(PATH(__file__))).is_reason @unittest.skipIf(_SKIP, _SKIP_REASON) class TestMarketingContactNews(UnitTests): """ :param: RE_LOGIN: 需要切换账号登录,当RE_LOGIN = True时,需要将LOGIN_INFO的value值全填写完成, 如果请求的账号中只有一家公司,那么company中的value就可以忽略不填写,否则会报错... :param: MODULE: 为当前运行的模块,根据当前运行的模块调用common中的对应的用例方法,需保留此变量方法 """ RE_LOGIN = False LOGIN_INFO = {"account": None, "password": None, "company": None} MODULE = os.path.abspath(__file__) def test_market_contact_news(self): """ 验证marketing页跳转页末news页 1、打开首页; 2、点击marketing;