失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > 接口测试系列:工作中所用(十:配置文件的读写操作 configparser模块)

接口测试系列:工作中所用(十:配置文件的读写操作 configparser模块)

时间:2019-06-24 12:43:54

相关推荐

接口测试系列:工作中所用(十:配置文件的读写操作 configparser模块)

global_cache.py

# -*- codeding: utf-8 -*-import configparserimport hashlibimport osfrom common.base import ENVclass globalInfo:def get_path(self):current_path = ''if os.name == "nt":current_path = os.path.abspath('.').split('\\')

#“scm-interface-test” 是接口测试工程文件名if current_path[-2] == "scm-interface-test":current_path = os.path.abspath('..') + '\\config\\'elif current_path[-1] == '' or current_path[-3] == 'scm-interface-test':current_path = os.path.abspath('../..') + '\\config\\'elif os.name == "posix":current_path = os.path.abspath('.').split('/')if current_path[-2] == "scm-interface-test":current_path = os.path.abspath('..') + '/config/'elif current_path[-1] == '' or current_path[-3] == 'scm-interface-test':current_path = os.path.abspath('../..') + '/config/'else:print('global_cache: dir name maybe changed!')return current_pathdef cfg_load(self):cf_env = configparser.ConfigParser()client = globalInfo()cf_env.read(client.get_path() + "test.ini", encoding="utf-8")return cf_envdef get_env(self):if ENV == 1 or ENV == 0:return 'zbrd'elif ENV == 2:return 'citest'

如果觉得《接口测试系列:工作中所用(十:配置文件的读写操作 configparser模块)》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。