Beispiel #1
0
 def get_data(self):
     """
     获取数据 data or data_all
     :return: 数据结果 type: list or dict
     """
     try:
         data = YamlReader(get_conf_file()).data()
     except:
         data = YamlReader(get_conf_file()).data_all()
     return data
 def get_keyword(self, name):
     # 1、读取配置文件,文件路径:绝对路径
     keyword_file = Conf.keywords_path
     # 2、YamlReader,data()
     reader = YamlReader(keyword_file).data()
     # 3、key获取值 name
     value = reader[name]
     return value
Beispiel #3
0
	def get_keyword(self,name):
		# 读取配置文件
		keyword_file = Conf.keywords_path
		# Yamlreader ,data()
		reader = YamlReader(keyword_file).data()
		# key 获取值 name
		value = reader[name]
		return value
Beispiel #4
0
from config import Conf
import os
from utils.YamlUtil import YamlReader
import pytest
from config.Conf import ConfigYaml
from utils.RequestsUtil import Request
#1、获取测试用例内容list
#获取testlogin.yml文件路径
test_file = os.path.join(Conf.get_data_path(), "testlogin.yml")
#print(test_file)
#使用工具类来读取多个文档内容
data_list = YamlReader(test_file).data_all()
print(data_list)
#2、参数化执行测试用例


@pytest.mark.parametrize("login", data_list)
def test_yaml(login):
    #初始化url,data
    url = ConfigYaml().get_conf_url() + login["url"]
    print("url %s" % url)
    data = login["data"]
    print("data %s" % data)
    #post请求
    request = Request()
    res = request.post(url, json=data)
    #打印结果
    print(res)


if __name__ == "__main__":
Beispiel #5
0
 def __init__(self):
     #读取yam文件把获取的路径写入
     self.con = YamlReader(file_yaml_path()).data()
Beispiel #6
0
def readSingleDocByUtils():
    from utils.YamlUtil import YamlReader
    res = YamlReader("./data.yml").data()
    print(res)
Beispiel #7
0
def readMultiDocByUtils():
    from utils.YamlUtil import YamlReader
    res = YamlReader("./data.yml").data_all()
Beispiel #8
0
# 导包
import yaml
from utils.YamlUtil import YamlReader
# 定义yaml文件路径

# 获取文件流对象
# with open('./data.yml', 'r', encoding='utf-8')as f:
# 通过safe_load 读取文件流
# r = yaml.safe_load(f)
# print('读取到的数据:', r)
# print('读取到的数据的数据类型:', type(r))

# with open('./data1.yml', 'r', encoding='utf-8') as f:
# r = yaml.safe_load_all(f)
# for i in r:
# print(i)
res1 = YamlReader('./data.yml').data()
res = YamlReader('./data1.yml').data_all()
print(res1)
print(res)

Beispiel #9
0
import json
import os
import allure
import pytest
from common.handle_test import Handle
from config import Conf
from config.Conf import ConfigYaml
from utils.Assert import Assertions
from utils.YamlUtil import YamlReader


getDataIndexValueTreeList = os.path.join(Conf.get_data_path(), "TITAN_16getDataIndexValueTreeList.yml")
data_index_value_tree_list = YamlReader(getDataIndexValueTreeList).read_data_all()

data_list = list()
def get_data(second_data):
    a = list()
    if second_data["title"] is None or "title" not in second_data.keys():
        title1 = " "
    else:
        title1 = second_data["title"]
    if "children" in second_data and second_data["children"]:
        for third_data in second_data["children"]:
            return get_data(third_data)
    else:
        a.append(title1)
        b = "--".join(a)
        return data_list.append(b)

def get_indicator_data(response_data):
Beispiel #10
0
 def __init__(self):
     self.__config = YamlReader(get_config_file()).data()
Beispiel #11
0
 def __init__(self):
     self.config = YamlReader(get_config_file()).read_data()
     self.db_config = YamlReader(get_db_config_file()).read_data()
     self.login_config = YamlReader(get_config_login()).read_data()
Beispiel #12
0
import yaml
from utils.YamlUtil import YamlReader
# with open("./data.yaml","r",encoding="utf-8") as f:
#     r=yaml.safe_load(f)
#     print(r)


# with open("./data.yaml","r",encoding="utf-8") as f:
#     r = yaml.safe_load_all(f)
#     for i in r:
#         print(i)
#
# print(YamlReader("./data.yaml").data())
print(YamlReader("./data.yaml").data_all())
Beispiel #13
0
# encoding:utf8
from utils.YamlUtil import YamlReader
from conf import Conf
from appium import webdriver

# 1、通过yaml来读取caps.yml
reader = YamlReader(Conf.conf_caps)
data = reader.data()


# 2、结果,字典转换

def desired_caps():
    # 2、desired创建字典
    desired_caps = dict()
    # 3、platformName
    desired_caps['platformName'] = data['platformName']
    # 4、platformVersion
    desired_caps['platformVersion'] = data['platformVersion']
    # 5、deviceName
    desired_caps['deviceName'] = data['deviceName']
    # 6、启动程序的包名appPackage
    desired_caps["appPackage"] = data['appPackage']
    # 7、启动界面名appActivity
    desired_caps['appActivity'] = data['appActivity']
    # 解决中文
    desired_caps["unicodeKeyboard"] = data['unicodeKeyboard']
    desired_caps["resetKeyboard"] = data['resetKeyboard']

    # 获取toast automationName = uiautomator2
    desired_caps["automationName"] = data['automationName']
Beispiel #14
0
 def __init__(self):
     self.db_config = YamlReader((get_db_config_file())).yamldata()
     self.config = YamlReader((get_config_file())).yamldata()
	def get_keyword(self,name):
		keyword_file = Conf.keywords_path
		reader = YamlReader(keyword_file).data()
		value = reader[name]
		return value
Beispiel #16
0
 def __init__(self):
     self.config = YamlReader(get_config_file()).data()
     self.db_config = YamlReader(get_db_config_file()).data()
     self.env_config = YamlReader(get_env_conf_path()).data()
Beispiel #17
0
# encoding:utf8
"""
1、创建yaml格式文件:yaml,yml
2、读取这个yaml文件
3、输出这个文件
"""

# 2、读取yaml文件
# 1.导入yaml包
import yaml

# 2.打开文件 with open  with open(file, ‘r’, encoding='utf-8') as f:
# with open("yaml_demo.yml", "r", encoding='utf-8') as f:
# 3.yaml safe_load
# 单个文档
# data = yaml.safe_load(f)
# 多个文档
#    data = yaml.safe_load_all(f)
# 3、输出文件内容
#    for i in data:
#        print(i)
# print(data)

# 1.初始化yamutil,参数文件名称
# reader = YamlReader("yaml_demo.yml")
reader = YamlReader("../conf/caps.yml")
# 2.调用data方法,输出结果
data = reader.data()
# data = reader.data_all()
print(data)
Beispiel #18
0
#导入yaml
import yaml
#读取单个文档save_load
# with open("./data.yml","r",encoding="utf8") as f:
#     #读取yaml文件
#     r = yaml.safe_load(f)
# #输出
# print(r)

from utils.YamlUtil import YamlReader

res = YamlReader("./data.yml").data()
#多个
# res = YamlReader("./data_all.yml").data_all()
print(res)
Beispiel #19
0
 def __init__(self):
     self.config = YamlReader(get_config_file()).data()
     self.db_config = YamlReader(get_db_conf_get()).data()
Beispiel #20
0
# encoding=utf-8
import yaml
from utils.YamlUtil import YamlReader

# with open("./data.yml", "r", encoding="utf-8") as f:
#     r = yaml.safe_load_all(f)
#     for i in r:
#         print(i)
res = YamlReader("./data.yml").get_data_all()
print(res)
Beispiel #21
0
#print(os.path.dirname(__file__))
#print(os.path.dirname(os.path.dirname(__file__)))
from utils.YamlUtil import YamlReader

current = os.path.dirname(os.path.dirname(__file__))
#2、conf目录
conf_path = current + os.sep + "conf"
conf_path_yml = conf_path + os.sep + "conf.yml"

#print(conf_path)
#3、caps.yml
conf_caps = conf_path + os.sep + "caps.yml"
#print(conf_caps)

#log目录
log_path = current + os.sep + "logs"
#keywords文件目录
keywords_path = conf_path + os.sep + "keywords.yml"

#data目录
data_path = current + os.sep + "data"
#data测试用例文件
testcase_file = data_path + os.sep + "data.xls"
#report目录
report_path = current + os.sep + "report"

#1、通过yamlreader获取data
config = YamlReader(conf_path_yml).data()

#2、根据key来获取对应的内容
#print(config["EMAIL"])
Beispiel #22
0
 def __init__(self):
     self.con = YamlReader(get_config_yml()).data()
     self.db = YamlReader(get_db_file()).data()