Beispiel #1
0
def configpath(filename):
    path = filePath.get_Path()
    config_path = os.path.join(path, 'test_data', filename)
    print(config_path)
    config = configparser.ConfigParser()  # 调用外部的读取配置文件的方法
    config.read(config_path, encoding='utf-8')
    return config
Beispiel #2
0
#coding=utf-8
#!usr/bin/python
import unittest
import os
from public import base, HTMLTestRunnerCN
from oper import send_mail
import filePath
from oper import read_Config
import threading
path = filePath.get_Path()


def Run(testcase):
    #构建测试集
    test_dir = os.path.join(path, testcase)
    discover = unittest.defaultTestLoader.discover(test_dir,
                                                   pattern='test*.py')
    f = base.fp()
    fp = open(f, "wb")
    mail_config = read_Config.ReadConfig()
    title = mail_config.get_config_str('EMAIL', 'title')
    description = mail_config.get_config_str('EMAIL', 'description')
    tester = mail_config.get_config_str('EMAIL', 'tester')
    runner = HTMLTestRunnerCN.HTMLTestRunner(stream=fp,
                                             title=title,
                                             description=description,
                                             verbosity=2,
                                             tester=tester)
    runner.run(discover)
    fp.close()
    test_report = os.path.join(path, "report")
Beispiel #3
0
#coding=utf-8
#!usr/bin/python
import os
import configparser
import filePath  #引入我们自己的写的获取路径的类

path = filePath.get_Path(
)  #调用实例化,还记得这个类返回的路径为C:\Users\songlihui\PycharmProjects\dkxinterfaceTest
config_path = os.path.join(path, 'test_data', 'config.ini')  #项目目录+上后边文件夹及文件名
print(config_path)
config = configparser.ConfigParser()  #调用外部的读取配置文件的方法
config.read(config_path, encoding='utf-8')
print(config.sections())


class ReadConfig():
    def get_config_str(self, sections, option):
        value = config.get(sections, option)
        return value

    def get_config_int(self, section, option):
        value = config.getint(section, option)
        return value

    def get_config_boolean(self, section, option):
        value = config.getboolean(section, option)
        return value

    def get_config_float(self, section, option):
        value = config.getfloat(section, option)
        return value