api-engine-xin 0.0.22__tar.gz → 0.0.23__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.
Files changed (20) hide show
  1. {api_engine_xin-0.0.22 → api_engine_xin-0.0.23}/ApiEngine/BaseCase.py +32 -0
  2. {api_engine_xin-0.0.22 → api_engine_xin-0.0.23}/ApiEngine/testResult.py +1 -0
  3. {api_engine_xin-0.0.22 → api_engine_xin-0.0.23}/PKG-INFO +1 -1
  4. {api_engine_xin-0.0.22 → api_engine_xin-0.0.23}/api_engine_xin.egg-info/PKG-INFO +1 -1
  5. {api_engine_xin-0.0.22 → api_engine_xin-0.0.23}/setup.py +1 -1
  6. {api_engine_xin-0.0.22 → api_engine_xin-0.0.23}/ApiEngine/__init__.py +0 -0
  7. {api_engine_xin-0.0.22 → api_engine_xin-0.0.23}/ApiEngine/caseLog.py +0 -0
  8. {api_engine_xin-0.0.22 → api_engine_xin-0.0.23}/ApiEngine/core.py +0 -0
  9. {api_engine_xin-0.0.22 → api_engine_xin-0.0.23}/ApiEngine/dbClient.py +0 -0
  10. {api_engine_xin-0.0.22 → api_engine_xin-0.0.23}/ApiEngine/global_func.py +0 -0
  11. {api_engine_xin-0.0.22 → api_engine_xin-0.0.23}/LICENSE +0 -0
  12. {api_engine_xin-0.0.22 → api_engine_xin-0.0.23}/README.md +0 -0
  13. {api_engine_xin-0.0.22 → api_engine_xin-0.0.23}/api_engine_xin.egg-info/SOURCES.txt +0 -0
  14. {api_engine_xin-0.0.22 → api_engine_xin-0.0.23}/api_engine_xin.egg-info/dependency_links.txt +0 -0
  15. {api_engine_xin-0.0.22 → api_engine_xin-0.0.23}/api_engine_xin.egg-info/requires.txt +0 -0
  16. {api_engine_xin-0.0.22 → api_engine_xin-0.0.23}/api_engine_xin.egg-info/top_level.txt +0 -0
  17. {api_engine_xin-0.0.22 → api_engine_xin-0.0.23}/setup.cfg +0 -0
  18. {api_engine_xin-0.0.22 → api_engine_xin-0.0.23}/tests/Tools.py +0 -0
  19. {api_engine_xin-0.0.22 → api_engine_xin-0.0.23}/tests/__init__.py +0 -0
  20. {api_engine_xin-0.0.22 → api_engine_xin-0.0.23}/tests/runTest.py +0 -0
@@ -458,6 +458,10 @@ class BaseCase(CaseLogHandler):
458
458
  step_error = None
459
459
  response= None
460
460
  try:
461
+ # 重置响应属性,避免上一步骤的残留数据
462
+ self.status_code = ''
463
+ self.response_body = ''
464
+ self.response_headers = {}
461
465
  self.__setup_script(step)
462
466
  response = self.__send_request(step)
463
467
 
@@ -485,6 +489,33 @@ class BaseCase(CaseLogHandler):
485
489
  # 确保 teardown 在任何情况下都执行(如果 setup 已执行成功)
486
490
  # 注意:如果 __setup_script 都失败了,teardown 不应再执行
487
491
  self.__teardown_script(step, response)
492
+ # ★ 捕获该前置步骤的独立执行结果(响应/请求/断言/提取)
493
+ _req_body = getattr(self, 'request_body', '')
494
+ if isinstance(_req_body, bytes):
495
+ _req_body = _req_body.decode('utf-8', errors='replace')
496
+ _elapsed = ""
497
+ if response is not None:
498
+ try:
499
+ _elapsed = "{} ms".format(int(response.elapsed.total_seconds() * 1000))
500
+ except Exception:
501
+ pass
502
+ step_result = {
503
+ "title": title,
504
+ "status_code": getattr(self, 'status_code', ''),
505
+ "response_headers": dict(getattr(self, 'response_headers', {}) or {}),
506
+ "response_body": getattr(self, 'response_body', ''),
507
+ "request_body": _req_body,
508
+ "request_headers": dict(getattr(self, 'request_headers', {}) or {}),
509
+ "url": getattr(self, 'url', ''),
510
+ "method": getattr(self, 'method', ''),
511
+ "run_time": _elapsed,
512
+ "assert_info": list(self._assert_results),
513
+ "extract_info": list(self._extract_results),
514
+ }
515
+ self._precondition_results.append(step_result)
516
+ # 清空,避免累积到下一步骤
517
+ self._assert_results = []
518
+ self._extract_results = []
488
519
  self.info_log(f"{prefix}✅ [L{depth}] 前置完成: {title}")
489
520
 
490
521
  # ★ 根据 on_failure 决定是否继续
@@ -505,6 +536,7 @@ class BaseCase(CaseLogHandler):
505
536
  """执行用例"""
506
537
  start_time = time.time()
507
538
  self._precondition_errors = [] # 记录前置错误(供结果查询)
539
+ self._precondition_results = [] # 记录各前置步骤的独立执行结果
508
540
  self._extract_results = [] # 重置提取结果
509
541
  self._assert_results = [] # 重置断言结果
510
542
  case_name = data.get('title')
@@ -32,6 +32,7 @@ class TestResult:
32
32
  "run_time": getattr(test, "elapsed_ms", ""),
33
33
  "extract_info": getattr(test, "_extract_results", []),
34
34
  "assert_info": getattr(test, "_assert_results", []),
35
+ "precondition_results": getattr(test, "_precondition_results", []),
35
36
  }
36
37
 
37
38
  def add_success(self, test: BaseCase):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: api_engine_xin
3
- Version: 0.0.22
3
+ Version: 0.0.23
4
4
  Summary: 接口测试平台测试用例执行引擎
5
5
  Home-page: https://pypi.org/project/api_engine_xin/
6
6
  Author: Shawn
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: api-engine-xin
3
- Version: 0.0.22
3
+ Version: 0.0.23
4
4
  Summary: 接口测试平台测试用例执行引擎
5
5
  Home-page: https://pypi.org/project/api_engine_xin/
6
6
  Author: Shawn
@@ -12,7 +12,7 @@ with codecs.open(os.path.join(here, "README.md"), encoding="utf-8") as fh:
12
12
  # 核心配置
13
13
  setup(
14
14
  name="api_engine_xin", # ✅【必须改】pip install 这个名字!全网唯一,不能和PyPI上已有的包名重复
15
- version="0.0.22", # ✅【必须改】版本号,每次更新包都要升级版本(如0.0.2、0.1.0)
15
+ version="0.0.23", # ✅【必须改】版本号,每次更新包都要升级版本(如0.0.2、0.1.0)
16
16
  author="Shawn",# ✅【必须改】你的名字/昵称
17
17
  author_email="xiaoh0525@xiaoh.com",# ✅【必须改】你的注册PyPI的邮箱
18
18
  description="接口测试平台测试用例执行引擎", # ✅【必须改】一句话说明你的包是干嘛的
File without changes