Ejemplo n.º 1
0
    def __init__(self, cfname):
        self.data = ReadConfig("DB_CONFIG.ini")
        self.conn = pymysql.connect(
            host=self.data.get_db(cfname, "host"),
            user=self.data.get_db(cfname, "user"),
            password=self.data.get_db(cfname, "passwd"),
            charset="utf8",
            database=self.data.get_db(cfname, "dbname"),
            port=int(self.data.get_db(cfname, "port")),
            cursorclass=pymysql.cursors.DictCursor)

        self.cursor = self.conn.cursor()
Ejemplo n.º 2
0
#coding=utf-8
import os

from config.readconfig import ReadConfig

# Read configuration file
config_file_path = os.path.split(os.path.realpath(__file__))[0]
read_config = ReadConfig(os.path.join(config_file_path, 'config.ini'))
# Project parameter setting
prj_path = read_config.getValue('projectConfig', 'project_path')
# Log path
log_path = os.path.join(prj_path, 'report', 'log')
# Screenshot file path
img_path = os.path.join(prj_path, 'report', 'image')
#Exception screenshot file path
eximg_path = os.path.join(prj_path, 'report', 'exception_img')
#Test report path
report_path = os.path.join(prj_path, 'report', 'test_report')
#Upload the autoit file path
auto_path = os.path.join(prj_path, 'up_files', 'autoit_pic')
#
yaml_path = os.path.join(prj_path, 'config', 'readyaml')
# Default browser
browser = 'chrome'
# Test data path
data_path = os.path.join(prj_path, '', 'testdata')
Ejemplo n.º 3
0
 def __init__(self, robotname):
     filename = 'RobotConfig.ini'
     test = ReadConfig(filename)
     self.tokenurl = test.get_db(robotname, "tokenrul")
     self.secret = test.get_db(robotname, "secret")
     self.url = self.make_url()
Ejemplo n.º 4
0
import requests
from config.readconfig import ReadConfig

read_config = ReadConfig()


class ConfigHttp():
    def __init__(self, section, host, port, timeout):
        '''
        读取配置config.ini文件中的全局配置信息
        :param section 配置文件中【节】的名字
        :param host: 配置文件中name的名字
        :param port: 配置文件中name的名字
        :param timeout: 配置文件中name的名字
        '''
        self.host = read_config.get_config_value(section, host)
        self.port = read_config.get_config_value(section, port)
        self.timeout = read_config.get_config_value(section, timeout)
        self.headers = {}
        self.params = {}
        self.data = {}
        self.url = None
        self.files = {}
        self.log = Log.get_log()
        self.logger = self.log.get_logger()

    def set_url(self, url):
        '''拼接完整的接口测试地址'''
        self.url = self.host + url

    def set_headers(self, headers):
Ejemplo n.º 5
0
import os
from email.mime.text import MIMEText
from email.header import Header
from smtplib import SMTP_SSL
from email.mime.multipart import MIMEMultipart
from config.readconfig import ReadConfig
from datetime import datetime

# 将ReadConfig类的get_email_config方法赋值给变量read_config
read_config = ReadConfig().get_email_config


def send_report(file):
    '''发送测试报告'''
    with open(file, "rb") as f:
        mail_body = f.read()

    host_server = read_config("mail_host")
    user = read_config("mail_user")
    pwd = read_config("mail_pass")
    reciever = read_config("receiver")
    sender = read_config("sender")

    mail_title = read_config("subject")

    msg = MIMEMultipart()
    msg["Subject"] = Header(mail_title, "utf-8")
    msg["From"] = sender

    msg.attach(MIMEText(mail_body, "html", "utf-8"))