# -*- coding:utf-8 -*-

'''
@project: ApiAutoTest
@author: Jimmy
@file: read_config.py
@ide: PyCharm Community Edition
@time: 2018-12-21 13:53
@blog: https://www.cnblogs.com/gotesting/ ''' import configparser
import os
from Common import contants # 创建实例
# 加载配置文件
# 根据section option获取值 class ReadConfig: # 初始化函数:实例化conf对象,读取传入的配置文件
def __init__(self):
self.conf = configparser.ConfigParser()
file = os.path.join(contants.conf_dir,'global.conf')
self.conf.read(file)
if self.get_config_boolean('switch','button'):
test_conf = os.path.join(contants.conf_dir,'test_env.conf')
self.conf.read(test_conf)
else:
online_conf = os.path.join(contants.conf_dir,'online_env.conf')
self.conf.read(online_conf) def get_config_str(self,section,option):
return self.conf.get(section,option) def get_config_boolean(self,section,option):
return self.conf.getboolean(section,option) def get_config_int(self,section,option):
return self.conf.getint(section,option) def get_config_float(self,section,option):
return self.conf.getfloat(section,option)

python - 接口自动化测试 - ReadConfig - 读取配置文件封装的更多相关文章

  1. python - 接口自动化测试 - MysqlUtil - 数据库操作封装

    # -*- coding:utf-8 -*- ''' @project: ApiAutoTest @author: Jimmy @file: mysql_util.py @ide: PyCharm C ...

  2. python接口自动化测试--批量读取数据

    为了便于维护,python接口自动化测试用例可以利用xlrd模块读取excal表格进行数据分离.我们可以利用xlrd模块的row_values()和cell_value()两种方法读取Excal表格. ...

  3. 一篇文章告诉你Python接口自动化测试中读取Text,Excel,Yaml文件的方法

    前言 不管是做Ui自动化和接口自动,代码和数据要分离,会用到Text,Excel,Yaml.今天讲讲如何读取文件数据 Python也可以读取ini文件,传送门 记住一点:测试的数据是不能写死在代码里面 ...

  4. python - 接口自动化测试 - ReadExcel - 读取测试数据封装

    # -*- coding:utf-8 -*- ''' @project: ApiAutoTest @author: Jimmy @file: read_excel.py @ide: PyCharm C ...

  5. python - 接口自动化测试 - GetLog - 日志类封装

    # -*- coding:utf-8 -*- ''' @project: ApiAutoTest @author: Jimmy @file: get_logger.py @ide: PyCharm C ...

  6. python - 接口自动化测试 - HttpRequest - 接口测试类封装

    # -*- coding:utf-8 -*- ''' @project: ApiAutoTest @author: Jimmy @file: http_request.py @ide: PyCharm ...

  7. Python接口自动化测试框架实战 从设计到开发

    第1章 课程介绍(不要错过)本章主要讲解课程的详细安排.课程学习要求.课程面向用户等,让大家很直观的对课程有整体认知! 第2章 接口测试工具Fiddler的运用本章重点讲解如何抓app\web的htt ...

  8. 基于Python接口自动化测试框架+数据与代码分离(进阶篇)附源码

    引言 在上一篇<基于Python接口自动化测试框架(初级篇)附源码>讲过了接口自动化测试框架的搭建,最核心的模块功能就是测试数据库初始化,再来看看之前的框架结构: 可以看出testcase ...

  9. python接口自动化测试二十七:密码MD5加密 ''' MD5加密 ''' # 由于MD5模块在python3中被移除 # 在python3中使用hashlib模块进行md5操作 import hashlib # 待加密信息 str = 'asdas89799,.//plrmf' # 创建md5对象 hl = hashlib.md5() # Tips # 此处必须声明encode # 若写法为

    python接口自动化测试二十七:密码MD5加密   ''' MD5加密 '''# 由于MD5模块在python3中被移除# 在python3中使用hashlib模块进行md5操作import has ...

随机推荐

  1. WPS去掉英语单词下面的红斜线

    我们在使用WPS的时候,经常会用到英语但是,但是在编码的时候,有些单词是缩写形成的,WPS就会自动验证,产生红色波浪线,提示我们单词写错的问题,那看起来就显得很不美观别扭 那么我们不想要这个红斜杠,怎 ...

  2. window7防火墙无法更改某些设置,错误代码0×80070422

    原因:这是由于管理工具的服务中的windows防火墙被禁用了. 解决方案:在window7中点击控制面板,然后点击管理工具,在点服务,然后找到windows firewall 然后将其改为自动就就可以 ...

  3. leetcode——2

    1. 题目 Add Two Numbers You are given two linked lists representing two non-negative numbers. The digi ...

  4. linux 命令——23 目录结构

    对于每一个Linux学习者来说,了解Linux文件系统的目录结构,是学好Linux的至关重要的一步.,深入了解linux文件目录结构的标准和每个目录的详细功能,对于我们用好linux系统只管重要,下面 ...

  5. 学习Rust Book之写Cargo配置文件

    不知道为什么这个文件就是编译不过 [package] name = "hello_world" version = "0.0.1" author = " ...

  6. selenium 使用键盘时 提示java.lang.IllegalArgumentException: Key Down / Up events only make sense for modifier keys.

    输入某个内容后,使用enter键进行确认,最开始使用方式为: driver.findElement(By.xpath("//input[@name='supplier_name'][@id= ...

  7. 【BZOJ4571】[SCOI2016] 美味(主席树)

    点此看题面 大致题意: 给你一个序列\(a\),然后每次询问\(max_{i=l}^r(a_i+x)\ xor\ b\). 大致思路 首先,我们要知道一个简单的性质:位运算时位与位之间是互不影响的. ...

  8. Angular2--显示数据

    1.插值表达式 要显示组件的属性,最简单的方式就是通过插值表达式来绑定属性名.要使用插值表达式,就把属性名包裹在双花括号里放进视图模板,如 {{}} eg: <h1>{{ name }}& ...

  9. Being a Good Boy in Spring Festival(博弈)

    Being a Good Boy in Spring Festival Problem Description一年在外 父母时刻牵挂春节回家 你能做几天好孩子吗寒假里尝试做做下面的事情吧 陪妈妈逛一次 ...

  10. 2018.6.9 MyEclipse连接Oracle数据库方法及步骤

    在windows栏找到showXXX 然后选择最后一个others 找到Database 然后选择oracle 接着就是jar包的问题了 这个不同于mysql oracle如果装在了本机上面可以在文件 ...