# from testFile import getPathInfo, readConfig
sys.path.append("./")
from testFile import readConfig
from testFile import getPathInfo

read_conf = readConfig.readConfig()
subject = read_conf.get_email("subject")
app = str(read_conf.get_email("app"))
address = read_conf.get_email("address")
toAddress = read_conf.get_email("toAddress")
password = read_conf.get_email("password")
smtpServer = read_conf.get_email("smtpServer")
smtpServer_host = read_conf.get_email("smtpServer_host")
mail_path = os.path.join(
    getPathInfo.get_Path().replace("\\testFile", ""), "result", "report.html"
)


class send_email:
    def outlook(self):
        olook = win32.Dispatch("%s.Application" % app)
        mail = olook.CreateItem(0)
        mail.To = address
        mail.Subject = str(datetime.datetime.now())[0:19] + "%s" % subject
        mail.Attachments.Add(mail_path, 1, 1, "myFile")
        content = """
                执行测试中....
                测试已完成!!!
                生成报告中....
                报告已生成....
# -*- coding:utf-8 -*-
import os
import configparser
from testFile import getPathInfo  # 引入我们自己的写的获取路径的类

path = getPathInfo.get_Path(
)  # 调用实例化,还记得这个类返回的路径为C:\Users\songlihui\PycharmProjects\dkxinterfaceTest
config_path = os.path.join(
    path, 'config.ini'
)  # 这句话是在path路径下再加一级,最后变成C:\Users\songlihui\PycharmProjects\dkxinterfaceTest\config.ini
config = configparser.ConfigParser()  # 调用外部的读取配置文件的方法
config.read(config_path, encoding='utf-8')
smtp_server = config.get('email', 'smtp_server')
sender = config.get('email', 'sender')
psw = config.get('email', 'psw')
receiver = config.get('email', 'receiver')
port = config.get('email', 'port')


class ReadConfig():
    def get_http(self, name):
        value = config.get('HTTP', name)
        return value

    def get_email(self, name):
        value = config.get('EMAIL', name)
        return value

    def get_mysql(self, name):  # 写好,留以后备用。但是因为我们没有对数据库的操作,所以这个可以屏蔽掉
        value = config.get('DATABASE', name)
        return value
Exemple #3
0
import os
import sys

sys.path.append("./")
from testFile import getPathInfo
from xlrd import open_workbook

path = getPathInfo.get_Path()


class readExcel:
    def get_xls(self, xls_name, sheet_name):
        cls = []
        # 获取用例文件路径
        xlsPath = os.path.join(path, "case", xls_name)
        file = open_workbook(xlsPath)  # 打开用例Excel
        sheet = file.sheet_by_name(sheet_name)  # 获得打开Excel的sheet
        # 获取这个sheet内容行数
        nrows = sheet.nrows
        for i in range(nrows):
            if sheet.row_values(i)[0] != u"case_name":
                cls.append(sheet.row_values(i))
        return cls


if __name__ == "__main__":
    print(readExcel().get_xls("userCase.xlsx", "login"))
    print(readExcel().get_xls("userCase.xlsx", "login")[0][1])
    print(readExcel().get_xls("userCase.xlsx", "login")[1][2])