Exemplo n.º 1
0
def URL():
    readcon = readConfig.ReadConfig()
    baseurl = readcon.get_http('baseurl')
    port = readcon.get_http('port')
    app = readcon.get_http('app')
    url = baseurl+':'+port+app
    return url
Exemplo n.º 2
0
import os
from testFile import readConfig
import logging
from datetime import datetime
import threading
from testFile import getpathInfo

localReadConfig = readConfig.ReadConfig()


class Log:
    def __init__(self):
        global logPath, resultPath, proDir
        path = getpathInfo.get_path()  #获取teseFile文件路径
        proDir = os.path.dirname(path)  #获取interface路径,也就是项目路径

        # print(proDir)
        resultPath = os.path.join(proDir,
                                  "result")  #把得到的结果result文件放入interface路径下
        # print(resultPath)
        if not os.path.exists(resultPath):
            os.mkdir(resultPath)
        logPath = os.path.join(
            resultPath, str(datetime.now().strftime("%Y%m%d")))  #%Y%m%d%H%M%S
        # print(logPath)
        if not os.path.exists(logPath):
            os.mkdir(logPath)
        self.logger = logging.getLogger()
        #设置日志级别info以上的
        self.logger.setLevel(logging.INFO)
Exemplo n.º 3
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2018/11/8 16:25
# @Author : xx
# @Site :
# @File : test11.py
# @Software: PyCharm

#获取接口的URL
from testFile import readConfig
from testFile import readExcel

readConfig = readConfig.ReadConfig()  #实例化readConfig类,用于读取配置文件config.ini文件


class geturl_Now():  #定义一个方法,读取配置文件中的协议和host,组合成url
    def get_url(self):

        now_url = readConfig.get_http('scheme') + '://' + readConfig.get_http(
            'baseurl')  #从config.ini文件获取协议和host
        return now_url


# print(geturl_Now().get_url()) #Geturl_Now()就是实例化类。不带参数会默认self
#读取表格数据作为请求的参数
Exemplo n.º 4
0
# -*- coding: utf-8 -*-
# @Time : 2019/10/21 21:58
# @Author : Ji
# @File : getpathInfo.py
from testFile import readConfig as readConfig

readconfig = readConfig.ReadConfig()


class geturlParams():  # 定义一个方法,将从配置文件中读取的进行拼接
    def get_Url(self):
        new_url = readconfig.get_http('scheme') + '://' + readconfig.get_http(
            'baseurl') + ':8888' + '/login' + '?'
        #logger.info('new_url'+new_url)
        return new_url


if __name__ == '__main__':  # 验证拼接后的正确性
    print(geturlParams().get_Url())
Exemplo n.º 5
0
import os
import win32com.client as win32
import datetime
import testFile.getpathInfo as getpathInfo
import testFile.readConfig as readConfig

read_conf = readConfig.ReadConfig()
subject = read_conf.get_email('subject')  # 从配置文件中读取,邮件主题
app = str(read_conf.get_email('app'))  # 从配置文件中读取,邮件类型
addressee = read_conf.get_email('addressee')  # 从配置文件中读取,邮件收件人
cc = read_conf.get_email('cc')  # 从配置文件中读取,邮件抄送人
mail_pathA = os.path.join('D:/python_project/zidonghua', 'result',
                          'report.html')  # 获取测试报告路径
mail_path = mail_pathA.replace('\\', '/')
print(mail_path + "------")
print(getpathInfo.get_path())


class send_email():
    def outlook(self):
        olook = win32.Dispatch("%s.Application" % app)
        mail = olook.CreateItem(0)
        mail.To = addressee  # 收件人
        # mail.CC = cc  # 抄送
        mail.Subject = str(
            datetime.datetime.now())[0:19] + '%s' % subject  # 邮件主题
        mail.Attachments.Add(mail_path, 1, 1, "myFile")
        content = """
                    执行测试中……AAAA
                    测试已完成!!
                    生成报告中……
Exemplo n.º 6
0
import os
import common.HTMLTestRunner as HTMLTestRunner
import getpathInfo as getpathInfo
import unittest
import testFile.readConfig as readConfig
from common.configEmail import send_email
from common.Log import Logger
logname = Logger.logpath()
log = Logger(logname, level='debug')
send_mail = send_email()
#获得基础目录
path = getpathInfo.get_path()
# 返回path上级目录
pathshang = os.path.dirname(path)
on_off = readConfig.ReadConfig().get_email('on_off')


class AllTest:
    def __init__(self):
        global resultPath

        resultPath = os.path.join(pathshang, "result",
                                  "report.html")  # result/report1.html
        self.caseListFile = os.path.join(path,
                                         "caselist.txt")  # 配置执行哪些测试文件的配置文件路径
        self.caseFile = os.path.join(pathshang, "TestCase")  # 真正的测试断言文件路径
        self.caseList = []

    def set_case_list(self):
        """
        读取caselist.txt文件中的用例名称,并添加到caselist元素组
Exemplo n.º 7
0
from email.mime.image import MIMEImage
from email.header import Header
from email.header import make_header
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from common.Log import MyLog
from testFile import readConfig, getpathInfo
# from email.mime.application import MIMEApplication
# import threading
# import glob
# import zipfile
# from testFile.readConfig import ReadConfig
# import  configparser
# from testFile.getpathInfo import get_path

A = readConfig.ReadConfig()  #实例化对象,用来读取配置文件里的邮箱有关的内容


class SendEmail(object):
    def __init__(self,
                 username,
                 passwd,
                 recv,
                 title,
                 content,
                 email_host,
                 port,
                 ssl_port,
                 file=None,
                 ssl=False):