Example #1
0
 def __init__(self):
     self.mylog = MyLog('Sql查询')
     self.conf = readConfig()
     host = self.conf.getstr('mysql', 'host')
     user = self.conf.getstr('mysql', 'user')
     password = self.conf.getstr('mysql', 'pwd')
     port = self.conf.getint('mysql', 'port')
     cursorclass = pymysql.cursors.DictCursor
     self.mysql = pymysql.connect(host=host,
                                  user=user,
                                  password=password,
                                  port=port,
                                  cursorclass=cursorclass)
Example #2
0
 def test_logig(self, item):
     params = json.loads(DoRegex().replace(data=item['params']))
     url = readConfig().getstr('url', 'url') + item['url']
     resp = Request(url=url, method=item['method'], data=params)
     actual = resp.get_txt()
     try:
         self.assertEqual(actual, item['excepted'])
         self.mylog.debug('正在执行第{}个用例,测试参数: {},测试结果:{}'.format(item['caseid'], params, actual))
         result = 'Pass'
     except AssertionError as e:
         result = 'Filed'
         self.mylog.error('正在执行第{}个用例,测试参数: {},断言结果:{}'.format(item['caseid'], params, e))
         raise e
     finally:
         re.write_back(row=item['caseid'] + 1, column=7, value=actual)
         re.write_back(row=item['caseid'] + 1, column=8, value=result)
Example #3
0
class sendEmail(object):
    # -------------------------------------------------配置邮件属性------------------------------------------------
    r = readConfig()
    # 发送方邮箱
    sender = r.getEmail("sender")
    # 收件人邮箱,多个可以用list,单个如下
    # msg_to = ['**','**']
    receiver = r.getEmail("receiver")
    # 发送方邮箱账号
    username = r.getEmail("mail_user")
    # 发送方邮箱密码
    password = r.getEmail("mail_pass")
    # 发送方邮箱的服务器
    smtpserver = r.getEmail("mail_host")

    # -------------------------------------------------定义邮件最终配置信息------------------------------------------------
    def config_email(self):
        # 邮件主题
        subject = "邮件标题"
        # 邮件内容
        content = "邮件的内容"
        # 生成一个MIMEText对象(还有一些其他参数)
        self.msg = MIMEText(content)
        # 放入邮件主题
        self.msg['Subject'] = subject
        # 放入发件人
        self.msg['From'] = self.sender
        # 放入收件人
        self.msg['To'] = self.receiver


#-------------------------------------------------建立连接发送邮件------------------------------------------------

    def send_email(self):
        self.config_email()
        try:
            # 实例化smtp对象
            s = smtplib.SMTP()
            # 链接smtp服务器
            s.connect(self.smtpserver)
            # 登录
            s.login(self.username, self.password)
            # 发送邮件
            s.sendmail(self.sender, self.receiver, self.msg.as_string())
            print("邮件发送成功")
        except smtplib.SMTPException as msg:
            print(msg)
Example #4
0
#!-*-coding: utf-8 -*-
#!Time  : 2020/11/6 17:49
#!@Author : 张俊彬

import re
from common.readConfig import readConfig

conf = readConfig()


class contex:
    normal_user = conf.getother('test_user', 'normal_user')['user']
    normal_pwd = conf.getother('test_user', 'normal_user')['pwd']
    admin_user = conf.getother('test_user', 'admin_user')['user']
    admin_pwd = conf.getother('test_user', 'admin_user')['pwd']
    loanid_user = conf.getother('test_user', 'loanid_user')['user']
    loanid_pwd = conf.getother('test_user', 'loanid_user')['pwd']
    title = conf.getstr('project', 'title')
    amount = conf.getint('project', 'amount')


class DoRegex:
    def replace(self, data):
        res = re.findall('\$\{(.*?)\}', data)
        for item in res:
            value = getattr(contex, item)
            data = re.sub('\$\{(.*?)\}', value, data, count=1)
        return data

    def replace2(self, data):
        p = '\$\{(.*?)\}'
Example #5
0
 def setUp(self):
     self.read_path = readConfig().getstr(section='url', option='url')
     self.rc = readConfig()
     self.mylog = MyLog('recharge模块')
Example #6
0
#!Time  : 2020/11/13 12:27
#!@Author : 张俊彬
import pytest
import time
from selenium.webdriver import Chrome
from selenium.webdriver import ChromeOptions
'''fixture 作用域
fixture的参数中,有scope作用域:
1、function 每个test都会运行,默认值
2、class 每个class的所有test只运行一次
3、module 每个module 的所有test只运行一次
4、session 每个session 只运行一次
'''

from common.readConfig import readConfig
url  = readConfig().getstr('url','url')

@pytest.fixture(scope='class',autouse=True) # autouse=True 自动使用
def fixture_class():
    global driver
    # chrome_options = Options()  #设置无头浏览器
    # chrome_options.add_argument('--headless')
    # chrome_options.add_argument('--disable-gpu')
    # driver = Chrome(options=chrome_options, service_log_path=r"D:\ChromeLog\log.log")
    chrome_options = ChromeOptions()
    chrome_options.binary_location=r"C:\Users\zjb\AppData\Local\Google\Chrome\Application\chrome.exe"
    driver = Chrome(executable_path=r"D:\Python37\chromedriver.exe",chrome_options=chrome_options)
    driver.maximize_window()
    time.sleep(2)
    yield driver
    driver.quit()
Example #7
0
 def __init__(self, filename, sheetname):
     self.mylog = MyLog('Excel读写')
     self.filename = filename
     self.sheetname = sheetname
     self.read_conf = readConfig().getother('Testconf', 'module')
Example #8
0
 def setUp(self):
     self.rc = readConfig()
     self.read_path = self.rc.getstr(section='url', option='url')
     self.mylog = MyLog('register模块')