pytest-api-framework-alpha 0.1.8__tar.gz → 0.2.0__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.1.8 → pytest_api_framework_alpha-0.2.0}/PKG-INFO +1 -1
- {pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/base_class.py +3 -2
- {pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/conftest.py +12 -10
- {pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/pytest_api_framework_alpha.egg-info/PKG-INFO +1 -1
- {pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/setup.py +1 -1
- {pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/__init__.py +0 -0
- {pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/allure_report.py +0 -0
- {pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/db/__init__.py +0 -0
- {pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/db/mysql_db.py +0 -0
- {pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/db/redis_db.py +0 -0
- {pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/exit_code.py +0 -0
- {pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/extract.py +0 -0
- {pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/global_attribute.py +0 -0
- {pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/http_client.py +0 -0
- {pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/render_data.py +0 -0
- {pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/report.py +0 -0
- {pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/startapp.py +0 -0
- {pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/utils/__init__.py +0 -0
- {pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/utils/common.py +0 -0
- {pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/utils/encrypt.py +0 -0
- {pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/utils/log_util.py +0 -0
- {pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/utils/teams_util.py +0 -0
- {pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/utils/yaml_util.py +0 -0
- {pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/validate.py +0 -0
- {pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/pytest_api_framework_alpha.egg-info/SOURCES.txt +0 -0
- {pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/pytest_api_framework_alpha.egg-info/dependency_links.txt +0 -0
- {pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/pytest_api_framework_alpha.egg-info/requires.txt +0 -0
- {pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/pytest_api_framework_alpha.egg-info/top_level.txt +0 -0
- {pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/setup.cfg +0 -0
{pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/base_class.py
RENAMED
|
@@ -33,6 +33,7 @@ class BaseTestCase(object):
|
|
|
33
33
|
app_http = getattr(self.http, app)
|
|
34
34
|
domain = self.context.get(app).get("domain")
|
|
35
35
|
data = RenderData(data).render()
|
|
36
|
+
url = data.request.get("url")
|
|
36
37
|
data.request.url = self.replace_domain(data.request.url, domain)
|
|
37
38
|
self.response = getattr(app_http, account).request(data=data, kwargs=kwargs)
|
|
38
39
|
if self.response.status_code in UNAUTHORIZED_CODE:
|
|
@@ -60,9 +61,9 @@ class BaseTestCase(object):
|
|
|
60
61
|
request.update({"method": "get", "headers": {}, **kwargs})
|
|
61
62
|
return self.request(app=app, account=account, data=Box({"request": request}))
|
|
62
63
|
|
|
63
|
-
def put(self, app, account, url, data=None, **kwargs):
|
|
64
|
+
def put(self, app, account, url, data=None, json=None, **kwargs):
|
|
64
65
|
domain = self.context.get(app).get("domain")
|
|
65
|
-
request = {"url": urljoin(domain, url), "data": data}
|
|
66
|
+
request = {"url": urljoin(domain, url), "data": data, "json": json}
|
|
66
67
|
request.update({"method": "put", "headers": {}, **kwargs})
|
|
67
68
|
return self.request(app=app, account=account, data=Box({"request": request}))
|
|
68
69
|
|
|
@@ -116,7 +116,7 @@ def pytest_generate_tests(metafunc):
|
|
|
116
116
|
if not case_data:
|
|
117
117
|
case_data["_scenario"] = {"data": {}}
|
|
118
118
|
case_data["_belong_app"] = belong_app
|
|
119
|
-
metafunc.parametrize("data", [case_data, ], ids=['#
|
|
119
|
+
metafunc.parametrize("data", [case_data, ], ids=[f'{case_data.get("title", "")}#'], scope="function")
|
|
120
120
|
return
|
|
121
121
|
if case_data.get("request") is None:
|
|
122
122
|
case_data["request"] = dict()
|
|
@@ -135,7 +135,7 @@ def pytest_generate_tests(metafunc):
|
|
|
135
135
|
if not url:
|
|
136
136
|
# UPDATE: 有的步骤不需要请求接口 比如 只校验数据库, 去掉下面的校验
|
|
137
137
|
if not case_common.get("url"):
|
|
138
|
-
logger.warning(f"
|
|
138
|
+
logger.warning(f"{func_file_path} request中缺少必填字段: url", case_data)
|
|
139
139
|
# pytest.exit(ExitCode.YAML_MISSING_FIELDS)
|
|
140
140
|
else:
|
|
141
141
|
if url.strip().startswith("${"):
|
|
@@ -146,19 +146,19 @@ def pytest_generate_tests(metafunc):
|
|
|
146
146
|
if not method:
|
|
147
147
|
# UPDATE: 有的步骤不需要请求接口 比如 只校验数据库, 去掉下面的校验
|
|
148
148
|
if not case_common.get("method"):
|
|
149
|
-
logger.warning(f"
|
|
149
|
+
logger.warning(f"{func_file_path} request中缺少必填字段: method", case_data)
|
|
150
150
|
# pytest.exit(ExitCode.YAML_MISSING_FIELDS)
|
|
151
151
|
|
|
152
152
|
for key in ["title", "level"]:
|
|
153
153
|
if key not in case_data:
|
|
154
|
-
logger.
|
|
155
|
-
pytest.exit(ExitCode.YAML_MISSING_FIELDS)
|
|
154
|
+
logger.warning(f"{func_file_path} 缺少必填字段: {key}", case_data)
|
|
155
|
+
# pytest.exit(ExitCode.YAML_MISSING_FIELDS)
|
|
156
156
|
|
|
157
157
|
if case_data.get("mark"):
|
|
158
158
|
metafunc.function.marks = [case_data.get("mark"), case_data.get("level")]
|
|
159
159
|
else:
|
|
160
160
|
metafunc.function.marks = [case_data.get("level")]
|
|
161
|
-
|
|
161
|
+
|
|
162
162
|
scenarios = case_common.get("scenarios")
|
|
163
163
|
case_data_list = list()
|
|
164
164
|
if scenarios:
|
|
@@ -310,7 +310,7 @@ def sort(case_items):
|
|
|
310
310
|
def pytest_collection_finish(session):
|
|
311
311
|
"""获取最终排序后的 items 列表"""
|
|
312
312
|
# 过滤掉item名称是test_setup或test_teardown的
|
|
313
|
-
session.items = [item for item in session.items if item.name not in ["test_setup", "
|
|
313
|
+
session.items = [item for item in session.items if item.name not in ["test_setup", "test_teardown"]]
|
|
314
314
|
|
|
315
315
|
# 1. 筛选出带井号 名称带'#' 的item,并记录原始索引
|
|
316
316
|
hash_items_with_index = [(index, item) for index, item in enumerate(session.items) if "#" in item.name]
|
|
@@ -383,7 +383,7 @@ def pytest_runtest_call(item):
|
|
|
383
383
|
if ignore_error_and_continue == "false":
|
|
384
384
|
# setup方法执行失败,则主动标记用例执行失败,不会执行用例
|
|
385
385
|
if item.funcargs.get("setup_success") is False:
|
|
386
|
-
pytest.skip(
|
|
386
|
+
pytest.skip("test_before_scenario execute error")
|
|
387
387
|
# 判断上一个用例是否执行失败,如果上一个用例执行失败,则主动标记用例执行失败,不会执行用例(解决场景性用例,有一个失败则后续用例判为失败)
|
|
388
388
|
index = item.session.items.index(item)
|
|
389
389
|
current_cls_name = item.parent.name
|
|
@@ -396,8 +396,10 @@ def pytest_runtest_call(item):
|
|
|
396
396
|
1) == current_turn.group(1): # 确保是同一个类
|
|
397
397
|
status = getattr(prev_item, "status", None) # 访问 status 属性
|
|
398
398
|
skip_reason = getattr(prev_item, "skip_reason", None) # 访问 skip_reason 属性
|
|
399
|
-
if status == "skipped" and skip_reason in [
|
|
400
|
-
|
|
399
|
+
if status == "skipped" and skip_reason.strip() in [
|
|
400
|
+
"the previous method execution skipped",
|
|
401
|
+
"the previous method execution failed",
|
|
402
|
+
"test_before_scenario execute error"]:
|
|
401
403
|
pytest.skip("the previous method execution skipped")
|
|
402
404
|
elif status == "failed":
|
|
403
405
|
pytest.skip("the previous method execution failed")
|
|
File without changes
|
{pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/allure_report.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/db/__init__.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/db/mysql_db.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/db/redis_db.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/exit_code.py
RENAMED
|
File without changes
|
|
File without changes
|
{pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/global_attribute.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/http_client.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/render_data.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/utils/__init__.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/utils/common.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/utils/encrypt.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/utils/log_util.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/utils/teams_util.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.1.8 → pytest_api_framework_alpha-0.2.0}/framework/utils/yaml_util.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|