首页 > 其他 > 详细

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

时间:2018-12-10 17:07:00      阅读:143      评论:0      收藏:0      [点我收藏+]

global_cache.py


#
-*- codeding: utf-8 -*- import configparser import hashlib import os from common.base import ENV class 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_path def cfg_load(self): cf_env = configparser.ConfigParser() client = globalInfo() cf_env.read(client.get_path() + "test.ini", encoding="utf-8") return cf_env def get_env(self): if ENV == 1 or ENV == 0: return zbrd elif ENV == 2: return citest

 

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

原文:https://www.cnblogs.com/by170628/p/10096919.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!