pytest-api-framework-alpha 0.3.15__tar.gz → 0.3.18__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/PKG-INFO +1 -1
- {pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/base_class.py +5 -5
- {pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/conftest.py +18 -3
- {pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/utils/lark_util.py +16 -3
- {pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/pytest_api_framework_alpha.egg-info/PKG-INFO +1 -1
- {pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/setup.py +1 -1
- {pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/__init__.py +0 -0
- {pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/db/__init__.py +0 -0
- {pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/db/mysql_db.py +0 -0
- {pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/db/redis_db.py +0 -0
- {pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/exceptions.py +0 -0
- {pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/exit_code.py +0 -0
- {pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/extract.py +0 -0
- {pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/global_attribute.py +0 -0
- {pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/http_client.py +0 -0
- {pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/render_data.py +0 -0
- {pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/report.py +0 -0
- {pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/script.py +0 -0
- {pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/startapp.py +0 -0
- {pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/utils/__init__.py +0 -0
- {pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/utils/common.py +0 -0
- {pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/utils/date_util.py +0 -0
- {pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/utils/encrypt.py +0 -0
- {pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/utils/log_util.py +0 -0
- {pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/utils/mock_util.py +0 -0
- {pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/utils/yaml_util.py +0 -0
- {pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/validate.py +0 -0
- {pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/pytest_api_framework_alpha.egg-info/SOURCES.txt +0 -0
- {pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/pytest_api_framework_alpha.egg-info/dependency_links.txt +0 -0
- {pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/pytest_api_framework_alpha.egg-info/requires.txt +0 -0
- {pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/pytest_api_framework_alpha.egg-info/top_level.txt +0 -0
- {pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/setup.cfg +0 -0
{pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/base_class.py
RENAMED
|
@@ -43,7 +43,7 @@ class BaseTestCase(ExtendBaseTestCase):
|
|
|
43
43
|
response: ResponseUtil = None
|
|
44
44
|
context: Union[GlobalAttribute, Box] = None
|
|
45
45
|
config: Union[GlobalAttribute, Box] = None
|
|
46
|
-
# faker方法文档 https://
|
|
46
|
+
# faker方法文档 https://hellopython.readthedocs.io/zh-cn/latest/faker_generate_fake_data.html
|
|
47
47
|
faker: Faker = SingletonFaker(locale=FAKER_LANGUAGE).faker
|
|
48
48
|
env = CONTEXT.get("env")
|
|
49
49
|
logger: logger = logger
|
|
@@ -221,8 +221,8 @@ class BaseTestCase(ExtendBaseTestCase):
|
|
|
221
221
|
# 删除crm中钱包
|
|
222
222
|
crm = self.mysql_conn(db=self.db.DB_CAMP_CRM)
|
|
223
223
|
crm.execute(
|
|
224
|
-
f"delete from tbl_crypto_wallet where id in (select wallet_id from tbl_participant_crypto_wallet where participant_code='{participant_code}');")
|
|
225
|
-
crm.execute(f"delete from tbl_participant_crypto_wallet where participant_code='{participant_code}';")
|
|
224
|
+
f"delete from tbl_crypto_wallet where id in (select wallet_id from tbl_participant_crypto_wallet where wallet_tag ='MY HOT WALLET' and participant_code='{participant_code}');")
|
|
225
|
+
crm.execute(f"delete from tbl_participant_crypto_wallet where wallet_tag ='MY HOT WALLET' and participant_code='{participant_code}';")
|
|
226
226
|
|
|
227
227
|
# 重新生成新钱包
|
|
228
228
|
self.post(
|
|
@@ -253,8 +253,8 @@ class BaseTestCase(ExtendBaseTestCase):
|
|
|
253
253
|
# 删除crm中钱包
|
|
254
254
|
crm = self.mysql_conn(db=self.db.DB_CAMP_CRM)
|
|
255
255
|
crm.execute(
|
|
256
|
-
f"delete from tbl_crypto_wallet where id in (select crypto_wallet_id from tbl_buyer_crypto_wallet where participant_code='{buyer_participant_code}');")
|
|
257
|
-
crm.execute(f"delete from tbl_buyer_crypto_wallet where participant_code='{buyer_participant_code}';")
|
|
256
|
+
f"delete from tbl_crypto_wallet where id in (select crypto_wallet_id from tbl_buyer_crypto_wallet where wallet_tag ='MY HOT WALLET' and participant_code='{buyer_participant_code}');")
|
|
257
|
+
crm.execute(f"delete from tbl_buyer_crypto_wallet where wallet_tag ='MY HOT WALLET' and participant_code='{buyer_participant_code}';")
|
|
258
258
|
|
|
259
259
|
# 重新生成新钱包
|
|
260
260
|
self.post(
|
{pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/conftest.py
RENAMED
|
@@ -128,7 +128,9 @@ def pytest_generate_tests(metafunc):
|
|
|
128
128
|
# pytest.exit(ExitCode.CASE_YAML_NOT_EXIST)
|
|
129
129
|
# yml转json
|
|
130
130
|
test_data = CachedYamlLoader(data_path).load_yml()
|
|
131
|
-
|
|
131
|
+
if not test_data:
|
|
132
|
+
logger.warning(f"测试数据文件: {func_file_path} 内容为空")
|
|
133
|
+
return
|
|
132
134
|
# 测试用例公共数据
|
|
133
135
|
case_common = test_data.get("case_common")
|
|
134
136
|
# 忽略的用例直接跳过
|
|
@@ -296,13 +298,14 @@ def pytest_collection_modifyitems(items):
|
|
|
296
298
|
for mark in marks:
|
|
297
299
|
item.add_marker(mark)
|
|
298
300
|
|
|
301
|
+
|
|
299
302
|
def pytest_collection_finish(session):
|
|
300
303
|
"""获取最终排序后的 items 列表"""
|
|
301
|
-
logger.info(f"共收集到 {len(session.items)} 个测试用例")
|
|
302
304
|
if not session.items:
|
|
303
305
|
pytest.exit("未收集到用例")
|
|
304
306
|
# 过滤掉item名称是test_setup或test_teardown的
|
|
305
307
|
session.items = [item for item in session.items if item.name not in ["test_setup", "test_teardown"]]
|
|
308
|
+
logger.info(f"共收集到 {len(session.items)} 个测试用例")
|
|
306
309
|
|
|
307
310
|
# 1. 筛选出带井号 名称带'#' 的item,并记录原始索引
|
|
308
311
|
hash_items_with_index = [(index, item) for index, item in enumerate(session.items) if "#" in item.name]
|
|
@@ -532,6 +535,7 @@ def pytest_terminal_summary(terminalreporter, exitstatus, config):
|
|
|
532
535
|
if settings.ONLY_LINUX_NOTIFICATION:
|
|
533
536
|
if "linux" not in platform.platform().lower():
|
|
534
537
|
return
|
|
538
|
+
# 发送测试结果群消息
|
|
535
539
|
for webhook in settings.LARK_WEBHOOKS.get(CONTEXT.get("env")):
|
|
536
540
|
LarkUtil(webhook).send_test_report(
|
|
537
541
|
total=total,
|
|
@@ -540,8 +544,19 @@ def pytest_terminal_summary(terminalreporter, exitstatus, config):
|
|
|
540
544
|
skipped=skipped,
|
|
541
545
|
report_url=os.environ.get("ALLURE_REPORT_URL"),
|
|
542
546
|
job_name=os.environ.get("JOB_NAME"),
|
|
543
|
-
env=CONTEXT.get("env")
|
|
547
|
+
env=CONTEXT.get("env"),
|
|
548
|
+
command=CONTEXT.get("command")
|
|
544
549
|
)
|
|
550
|
+
# 发送测试结果统计
|
|
551
|
+
LarkUtil(settings.LARK_CHART_WEBHOOK).send_test_chart(
|
|
552
|
+
total=total,
|
|
553
|
+
passed=passed,
|
|
554
|
+
failed=failed,
|
|
555
|
+
skipped=skipped,
|
|
556
|
+
job_name=os.environ.get("JOB_NAME"),
|
|
557
|
+
env=CONTEXT.get("env")
|
|
558
|
+
)
|
|
559
|
+
|
|
545
560
|
|
|
546
561
|
def pytest_exception_interact(node, call, report):
|
|
547
562
|
"""
|
{pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/utils/lark_util.py
RENAMED
|
@@ -66,14 +66,15 @@ class LarkUtil:
|
|
|
66
66
|
data["timestamp"] = timestamp
|
|
67
67
|
return requests.post(self.url, headers=self.headers, data=json.dumps(data))
|
|
68
68
|
|
|
69
|
-
def send_test_report(self, total: int, passed: int, failed: int, skipped: int,
|
|
70
|
-
|
|
69
|
+
def send_test_report(self, total: int, passed: int, failed: int, skipped: int, env: str, job_name: str,
|
|
70
|
+
command: str, report_url: str = None):
|
|
71
71
|
"""自动化测试结果消息(Markdown)"""
|
|
72
72
|
try:
|
|
73
73
|
pass_rate = round(passed / (total - skipped) * 100, 2)
|
|
74
74
|
except ZeroDivisionError:
|
|
75
75
|
pass_rate = 0
|
|
76
76
|
markdown = f"""**执行环境:** {env}
|
|
77
|
+
**执行命令:** {command}
|
|
77
78
|
**执行完成时间:** {datetime.now().strftime("%Y-%m-%d %X")}
|
|
78
79
|
**执行用例总数:** {total}
|
|
79
80
|
**通过用例数:** {passed}
|
|
@@ -84,4 +85,16 @@ class LarkUtil:
|
|
|
84
85
|
if report_url:
|
|
85
86
|
markdown += f"\n**测试报告:** [点击查看测试报告]({report_url})"
|
|
86
87
|
title = f"【自动化测试结果】-{job_name} " if job_name else "【自动化测试结果】"
|
|
87
|
-
return self.send_markdown(title, markdown)
|
|
88
|
+
return self.send_markdown(title, markdown)
|
|
89
|
+
|
|
90
|
+
def send_test_chart(self, total: int, passed: int, failed: int, skipped: int, job_name: str, env: str):
|
|
91
|
+
|
|
92
|
+
return requests.post(self.url, headers=self.headers,
|
|
93
|
+
json={
|
|
94
|
+
"job": job_name,
|
|
95
|
+
"total": total,
|
|
96
|
+
"passed": passed,
|
|
97
|
+
"failed": failed,
|
|
98
|
+
"skiped": skipped,
|
|
99
|
+
"env": env
|
|
100
|
+
})
|
{pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/__init__.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/db/__init__.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/db/mysql_db.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/db/redis_db.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/exceptions.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/exit_code.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/extract.py
RENAMED
|
File without changes
|
|
File without changes
|
{pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/http_client.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/render_data.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/startapp.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/utils/__init__.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/utils/common.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/utils/date_util.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/utils/encrypt.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/utils/log_util.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/utils/mock_util.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/utils/yaml_util.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.3.15 → pytest_api_framework_alpha-0.3.18}/framework/validate.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|