zoukankan      html  css  js  c++  java
  • 接口测试系列:工作中所用(十:配置文件的读写操作 configparser模块)

    
    
    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'
  • 相关阅读:
    变量可变性问题
    Android 创建Listener监听器形式选择:匿名内部类?外部类?
    linux下安装zookeeper
    翻页工具类
    将哈夫曼树转化成二叉树
    Activity的启动流程分析
    题目1186:打印日期
    数据库设计--数据流图(DFD)
    c#基础之数组
    10.3.1 一个CONNECT BY的样例
  • 原文地址:https://www.cnblogs.com/by170628/p/10096919.html
Copyright © 2011-2022 走看看