Пример #1
0
 def __init__(self, driver: WebDriver = None):
     self.base_url = data.load_ini()['driver']['base_url']
     if driver is None:
         self._driver = webdriver.Chrome()
         self._driver.implicitly_wait(3)
         self._driver.get(self.base_url)
         self._driver.maximize_window()
     else:
         self._driver = driver
Пример #2
0
import pytest
import allure
import os
from common.logger import logger
from common.read_data import data

BASE_PATH = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
data_file_path = os.path.join(BASE_PATH, "config", "setting.ini")
api_root_url = data.load_ini(data_file_path)["host"]["api_root_url"]


@allure.feature('api_test')
@allure.story('验证获取币种价格')
class TestTokenPrice(object):
    @allure.feature('获取币种价格')
    @allure.story('获取成功')
    def test_get_price_success(self):
        return self
        logger.info("********** 开始执行用例 **************")
        assert 1 == 1

    @allure.feature('币种信息错误')
    @allure.story('获取不到币种信息')
    def test_get_price_fail(self):
        return self
        logger.info("********** 用例执行结束 **************")
        assert 4 == 3


if __name__ == '__main__':
    pytest.main(["-q", "-s", "test_price1.py"])
Пример #3
0
import configparser
from common.read_data import data
import os

file = 'config.ini'

con = configparser.ConfigParser()

con.read(file, encoding='utf-8')

section = con.sections()

item = dict(con.items('URL'))

# a = con.get('URL', 'test')
# b = con.getint('URL', 'port')
c = con.options('mysql')
d = con.items('mysql')
file_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'config',
                         'config.ini')
a = data.load_ini(file_path)
print(a["URL"])
Пример #4
0
import pymysql
import os
from common.read_data import data
from common.logger import logger

BASE_PATH = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
data_file_path = os.path.join(BASE_PATH, "config", "setting.ini")
data = data.load_ini(data_file_path)["mysql"]
# print(test_data)

DB_CONF = {
    "host": data["MYSQL_HOST"],
    "port": int(data["MYSQL_PORT"]),
    "user": data["MYSQL_USER"],
    "password": data["MYSQL_PASSWD"],
    "db": data["MYSQL_DB"]
}


class MysqlDb():
    def __init__(self, db_conf=DB_CONF):
        # 通过字典拆包传递配置信息,建立数据库连接
        self.conn = pymysql.connect(**db_conf, autocommit=True)
        # 通过 cursor() 创建游标对象,并让查询结果以字典格式输出
        self.cur = self.conn.cursor(cursor=pymysql.cursors.DictCursor)

    def __del__(self):  # 对象资源被释放时触发,在对象即将被删除时的最后操作
        # 关闭游标
        self.cur.close()
        # 关闭数据库连接
        self.conn.close()