aitest-kit 0.3.2__tar.gz → 0.3.4__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 (139) hide show
  1. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/PKG-INFO +4 -1
  2. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/README.md +3 -0
  3. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/codegen/emitter.py +12 -17
  4. aitest_kit-0.3.4/aitest_kit/codegen/file_rendering.py +72 -0
  5. aitest_kit-0.3.4/aitest_kit/codegen/flow_rendering.py +61 -0
  6. aitest_kit-0.3.4/aitest_kit/codegen/function_rendering.py +44 -0
  7. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/codegen/ir.py +0 -7
  8. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/codegen/ir_renderer.py +118 -187
  9. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/codegen/planner.py +58 -69
  10. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/codegen/profile_validator.py +49 -39
  11. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/codegen/promotion.py +5 -8
  12. aitest_kit-0.3.4/aitest_kit/codegen/resolved_profile.py +58 -0
  13. aitest_kit-0.3.4/aitest_kit/codegen/strategy.py +123 -0
  14. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/codegen/suite_runner.py +11 -3
  15. aitest_kit-0.3.4/aitest_kit/helpers/capture.py +281 -0
  16. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/report/cli.py +32 -1
  17. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/report/task_runner.py +30 -2
  18. aitest_kit-0.3.4/aitest_kit/runtime_context.py +39 -0
  19. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/README.md +3 -0
  20. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/aitest_config/refs/config-files.md +35 -0
  21. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/skills/test-codegen/refs/emitter_rules.md +1 -0
  22. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/skills/test-scaffold/refs/constraints.md +2 -0
  23. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit.egg-info/PKG-INFO +4 -1
  24. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit.egg-info/SOURCES.txt +10 -0
  25. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/pyproject.toml +1 -1
  26. aitest_kit-0.3.4/tests/test_capture.py +161 -0
  27. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/tests/test_codegen_ir.py +125 -0
  28. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/tests/test_codegen_planner.py +5 -4
  29. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/tests/test_codegen_profile_validator.py +72 -0
  30. aitest_kit-0.3.4/tests/test_codegen_resolved_profile.py +170 -0
  31. aitest_kit-0.3.4/tests/test_codegen_strategy.py +78 -0
  32. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/tests/test_codegen_suite_profile.py +49 -0
  33. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/tests/test_report_cli.py +168 -0
  34. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/LICENSE +0 -0
  35. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/__init__.py +0 -0
  36. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/cli.py +0 -0
  37. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/codegen/__init__.py +0 -0
  38. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/codegen/case_flow_planner.py +0 -0
  39. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/codegen/cli.py +0 -0
  40. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/codegen/explain.py +0 -0
  41. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/codegen/health.py +0 -0
  42. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/codegen/module_type.py +0 -0
  43. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/codegen/parser.py +0 -0
  44. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/codegen/profile.py +0 -0
  45. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/codegen/profile_merge.py +0 -0
  46. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/codegen/profile_schema.py +0 -0
  47. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/codegen/profile_validation_report.py +0 -0
  48. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/codegen/profile_variables.py +0 -0
  49. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/codegen/project_config.py +0 -0
  50. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/codegen/render_utils.py +0 -0
  51. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/codegen/structured_assertions.py +0 -0
  52. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/codegen/suite.py +0 -0
  53. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/codegen/suite_target.py +0 -0
  54. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/doctor.py +0 -0
  55. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/helpers/__init__.py +0 -0
  56. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/helpers/grpc_ops.py +0 -0
  57. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/helpers/http.py +0 -0
  58. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/helpers/request_binding.py +0 -0
  59. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/helpers/structured_assertions.py +0 -0
  60. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/init_workspace.py +0 -0
  61. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/registry/__init__.py +0 -0
  62. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/registry/cli.py +0 -0
  63. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/registry/loader.py +0 -0
  64. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/registry/models.py +0 -0
  65. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/registry/path_resolver.py +0 -0
  66. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/registry/selection.py +0 -0
  67. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/registry/task_loader.py +0 -0
  68. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/report/__init__.py +0 -0
  69. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/report/classifier.py +0 -0
  70. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/report/codegen_check.py +0 -0
  71. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/report/collector.py +0 -0
  72. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/report/paths.py +0 -0
  73. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/report/renderer.py +0 -0
  74. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/report/sanitizer.py +0 -0
  75. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/runtime_variables.py +0 -0
  76. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/__init__.py +0 -0
  77. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/.gitignore +0 -0
  78. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/AGENTS.md +0 -0
  79. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/CLAUDE.md +0 -0
  80. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/__init__.py +0 -0
  81. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/aitest_config/aitest.yaml +0 -0
  82. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/aitest_config/refs/assertion-strategy.md +0 -0
  83. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/aitest_config/refs/case-format.md +0 -0
  84. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/aitest_config/refs/l1-template.md +0 -0
  85. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/aitest_config/refs/l2-template.md +0 -0
  86. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/aitest_config/refs/mismatch-format.md +0 -0
  87. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/aitest_config/schemas/codegen_profile.schema.json +0 -0
  88. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/docs/.gitkeep +0 -0
  89. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/skills/README.md +0 -0
  90. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/skills/case-migrate/SKILL.md +0 -0
  91. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/skills/doc-gen/SKILL.md +0 -0
  92. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/skills/doc-gen/refs/templates.md +0 -0
  93. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/skills/doc-review/SKILL.md +0 -0
  94. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/skills/emitter-build/SKILL.md +0 -0
  95. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/skills/emitter-build/refs/patterns.md +0 -0
  96. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/skills/knowledge-build/SKILL.md +0 -0
  97. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/skills/test-codegen/SKILL.md +0 -0
  98. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/skills/test-codegen/refs/selector_reference.md +0 -0
  99. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/skills/test-design/SKILL.md +0 -0
  100. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/skills/test-fix/SKILL.md +0 -0
  101. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/skills/test-maintain/SKILL.md +0 -0
  102. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/skills/test-maintain/refs/routing.md +0 -0
  103. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/skills/test-scaffold/SKILL.md +0 -0
  104. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/skills/test-scaffold/refs/formats.md +0 -0
  105. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/test_workspace/generated/.gitkeep +0 -0
  106. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/test_workspace/knowledge/L0_system_architecture.md +0 -0
  107. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/test_workspace/knowledge/L1/.gitkeep +0 -0
  108. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/test_workspace/knowledge/L2/.gitkeep +0 -0
  109. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/test_workspace/knowledge/TEST_SPEC.md +0 -0
  110. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/test_workspace/plans/.gitkeep +0 -0
  111. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/test_workspace/reports/.gitkeep +0 -0
  112. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/test_workspace/results/.gitkeep +0 -0
  113. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/test_workspace/suites/.gitkeep +0 -0
  114. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/test_workspace/targets/.gitkeep +0 -0
  115. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/templates/project_workspace/test_workspace/tasks/.gitkeep +0 -0
  116. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/upgrade_workspace.py +0 -0
  117. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/workspace.py +0 -0
  118. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit/workspace_config.py +0 -0
  119. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit.egg-info/dependency_links.txt +0 -0
  120. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit.egg-info/entry_points.txt +0 -0
  121. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit.egg-info/requires.txt +0 -0
  122. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/aitest_kit.egg-info/top_level.txt +0 -0
  123. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/setup.cfg +0 -0
  124. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/tests/test_classifier.py +0 -0
  125. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/tests/test_codegen_health_report.py +0 -0
  126. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/tests/test_codegen_parser.py +0 -0
  127. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/tests/test_codegen_promotion.py +0 -0
  128. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/tests/test_codegen_promotion_reports.py +0 -0
  129. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/tests/test_codegen_protocol_detection.py +0 -0
  130. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/tests/test_codegen_suite_target.py +0 -0
  131. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/tests/test_collector.py +0 -0
  132. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/tests/test_doctor.py +0 -0
  133. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/tests/test_registry_contexts.py +0 -0
  134. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/tests/test_registry_maintenance_cli.py +0 -0
  135. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/tests/test_renderer.py +0 -0
  136. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/tests/test_runtime_variables.py +0 -0
  137. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/tests/test_sanitizer.py +0 -0
  138. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/tests/test_workspace_config.py +0 -0
  139. {aitest_kit-0.3.2 → aitest_kit-0.3.4}/tests/test_workspace_template.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aitest-kit
3
- Version: 0.3.2
3
+ Version: 0.3.4
4
4
  Summary: AI-assisted testing toolchain: docs → knowledge base → Markdown cases → pytest code → structured reports
5
5
  Author: tlzmw001
6
6
  License-Expression: MIT
@@ -155,6 +155,7 @@ aitest codegen --suite-file <suite.yaml> --validate-profile # profile 门禁
155
155
  aitest codegen --suite-file <suite.yaml> # 生成 pytest
156
156
  aitest codegen --suite-file <suite.yaml> --check # 检查 generated 是否过期
157
157
  aitest run --suite-file <suite.yaml> # 执行一个 suite
158
+ aitest run --suite-file <suite.yaml> --capture # 执行并写入 capture.jsonl
158
159
  aitest run --target <target> [--module <module>] # 按 target/module 回归
159
160
  aitest run --all # 全量回归
160
161
  aitest report --suite-file/--target/--all ... # 重渲染报告
@@ -168,6 +169,8 @@ AITEST_ENV_FILE=/tmp/test.env aitest run --suite-file <suite.yaml>
168
169
 
169
170
  报告只记录变量名,不记录变量值。完整选项见 `aitest --help`。
170
171
 
172
+ 排查失败时可加 `--capture`,运行目录下会生成一个 `capture.jsonl`。框架只自动捕获默认 HTTP 用例;自定义 fixture、gRPC 或 SDK 调用可以手动调用 `aitest_kit.helpers.capture.capture_io()`。在 generated 测试函数体内调用时,`capture_io()` 可自动归因到当前 case;显式传入 `case_id` 仍然有效。pytest fixture setup/teardown 阶段不在该 context 内。capture 不自动脱敏,敏感字段应在用户 fixture 中处理后再写入。
173
+
171
174
  ## AI Skills
172
175
 
173
176
  workspace 内置 agent-neutral 的 `skills/`,按环境复制到对应目录:
@@ -104,6 +104,7 @@ aitest codegen --suite-file <suite.yaml> --validate-profile # profile 门禁
104
104
  aitest codegen --suite-file <suite.yaml> # 生成 pytest
105
105
  aitest codegen --suite-file <suite.yaml> --check # 检查 generated 是否过期
106
106
  aitest run --suite-file <suite.yaml> # 执行一个 suite
107
+ aitest run --suite-file <suite.yaml> --capture # 执行并写入 capture.jsonl
107
108
  aitest run --target <target> [--module <module>] # 按 target/module 回归
108
109
  aitest run --all # 全量回归
109
110
  aitest report --suite-file/--target/--all ... # 重渲染报告
@@ -117,6 +118,8 @@ AITEST_ENV_FILE=/tmp/test.env aitest run --suite-file <suite.yaml>
117
118
 
118
119
  报告只记录变量名,不记录变量值。完整选项见 `aitest --help`。
119
120
 
121
+ 排查失败时可加 `--capture`,运行目录下会生成一个 `capture.jsonl`。框架只自动捕获默认 HTTP 用例;自定义 fixture、gRPC 或 SDK 调用可以手动调用 `aitest_kit.helpers.capture.capture_io()`。在 generated 测试函数体内调用时,`capture_io()` 可自动归因到当前 case;显式传入 `case_id` 仍然有效。pytest fixture setup/teardown 阶段不在该 context 内。capture 不自动脱敏,敏感字段应在用户 fixture 中处理后再写入。
122
+
120
123
  ## AI Skills
121
124
 
122
125
  workspace 内置 agent-neutral 的 `skills/`,按环境复制到对应目录:
@@ -16,19 +16,13 @@ from aitest_kit.codegen.module_type import (
16
16
  )
17
17
  from aitest_kit.codegen.parser import ParseResult
18
18
  from aitest_kit.codegen.planner import build_file_ir
19
- from aitest_kit.codegen.profile import (
20
- load_profile_case_bodies,
21
- load_profile_case_fixtures,
22
- load_profile_case_flows,
23
- load_profile_extra_imports,
24
- load_profile_yaml,
25
- load_profile_rules,
26
- RuntimeProfile,
27
- )
19
+ from aitest_kit.codegen.profile import RuntimeProfile
28
20
  from aitest_kit.codegen.project_config import (
29
21
  DEFAULT_PROJECT,
30
22
  ProjectConfig,
31
23
  )
24
+ from aitest_kit.codegen.resolved_profile import resolve_profile
25
+ from aitest_kit.codegen.strategy import has_marker, skip_reason_from_markers
32
26
 
33
27
 
34
28
  # ---------------------------------------------------------------------------
@@ -94,12 +88,13 @@ def emit_file(
94
88
  diagnostics=list(profile_path.diagnostics),
95
89
  )
96
90
 
97
- profile_rules = load_profile_rules(profile_path) if profile_path else []
98
- extra_imports = load_profile_extra_imports(profile_path) if profile_path else []
99
- case_fixtures = load_profile_case_fixtures(profile_path) if profile_path else {}
100
- case_bodies = load_profile_case_bodies(profile_path) if profile_path else {}
101
- case_flows = load_profile_case_flows(profile_path) if profile_path else {}
102
- profile_data = load_profile_yaml(profile_path) if profile_path else {}
91
+ resolved_profile = resolve_profile(profile_path)
92
+ profile_rules = resolved_profile.rules
93
+ extra_imports = resolved_profile.extra_imports
94
+ case_fixtures = resolved_profile.case_fixtures
95
+ case_bodies = resolved_profile.case_bodies
96
+ case_flows = resolved_profile.case_flows
97
+ profile_data = resolved_profile.raw
103
98
  proj = project or DEFAULT_PROJECT
104
99
 
105
100
  ctx = EmitContext(
@@ -150,8 +145,8 @@ def emit_file(
150
145
  if ctx.shared_config.base_request_http is None:
151
146
  uncovered = [
152
147
  tc.id for tc in parse_result.cases
153
- if not any("可行性存疑" in m for m in tc.markers)
154
- and not any("manual" in m.lower() for m in tc.markers)
148
+ if not skip_reason_from_markers(tc.markers)
149
+ and not has_marker(tc.markers, "manual")
155
150
  and tc.id not in ctx.case_bodies
156
151
  and tc.id not in case_flows
157
152
  ]
@@ -0,0 +1,72 @@
1
+ """Rendering helpers for generated pytest files."""
2
+ from __future__ import annotations
3
+
4
+ from pathlib import Path
5
+ from typing import Any
6
+
7
+ from aitest_kit.codegen.render_utils import dict_to_python
8
+
9
+
10
+ def render_header(
11
+ ctx: Any,
12
+ *,
13
+ has_profile_variables: bool = False,
14
+ has_structured_assertions: bool = False,
15
+ has_default_http: bool = False,
16
+ has_case_context: bool = False,
17
+ ) -> list[str]:
18
+ regenerate_hint = _regenerate_hint(ctx)
19
+ lines = [
20
+ f"# Auto-generated from {ctx.source_path}",
21
+ f"# DO NOT EDIT — regenerate with: {regenerate_hint}",
22
+ ]
23
+ lines.extend([
24
+ "import pytest",
25
+ ctx.project.helper_import,
26
+ ])
27
+ if ctx.shared_config.base_request_http:
28
+ lines.append("from aitest_kit.helpers.request_binding import build_request")
29
+ if has_default_http:
30
+ lines.append("from aitest_kit.helpers.capture import capture_io")
31
+ if has_case_context:
32
+ lines.append("from aitest_kit.runtime_context import reset_case_context, set_case_context")
33
+ if has_profile_variables:
34
+ lines.append("from aitest_kit.runtime_variables import resolve_profile_variables")
35
+ if has_structured_assertions:
36
+ lines.append("from aitest_kit.helpers import structured_assertions as aitest_assertions")
37
+ lines.extend(ctx.extra_imports)
38
+ return lines
39
+
40
+
41
+ def render_base_request(ctx: Any) -> list[str]:
42
+ body = ctx.shared_config.base_request_http
43
+ if not body:
44
+ return []
45
+ lines = ["", ""]
46
+ sanitized = dict(body)
47
+ for key in ctx.project.default_request.auto_fields:
48
+ if key in sanitized:
49
+ sanitized[key] = None
50
+ lines.append(f"BASE_REQUEST = {dict_to_python(sanitized)}")
51
+ return lines
52
+
53
+
54
+ def render_req_helper() -> list[str]:
55
+ return [
56
+ "",
57
+ "",
58
+ "def _req(*, auto_fields=None, overrides=None, patches=None) -> dict:",
59
+ " return build_request(",
60
+ " BASE_REQUEST,",
61
+ " auto_fields=auto_fields or {},",
62
+ " overrides=overrides or {},",
63
+ " patches=patches or [],",
64
+ " )",
65
+ ]
66
+
67
+
68
+ def _regenerate_hint(ctx: Any) -> str:
69
+ suite_manifest = Path(ctx.source_path).parent / "suite.yaml"
70
+ if suite_manifest.exists():
71
+ return f"aitest codegen --suite-file {suite_manifest}"
72
+ return "aitest codegen --suite-file <suite.yaml>"
@@ -0,0 +1,61 @@
1
+ """Rendering helpers for structured case_flow steps."""
2
+ from __future__ import annotations
3
+
4
+ from typing import Any
5
+
6
+ from aitest_kit.codegen.render_utils import dict_to_python_compact
7
+
8
+
9
+ def request_var_name(case_id: str) -> str:
10
+ return "__request_" + case_id.lower().replace("-", "_")
11
+
12
+
13
+ def render_flow_value(
14
+ value: Any,
15
+ *,
16
+ current_case_id: str,
17
+ request_vars: dict[str, str],
18
+ ) -> str:
19
+ if isinstance(value, dict):
20
+ keys = set(value)
21
+ if keys == {"request_ref"}:
22
+ ref = value["request_ref"]
23
+ ref_case_id = current_case_id if ref == "self" else str(ref)
24
+ return request_vars.get(ref_case_id, request_var_name(ref_case_id))
25
+ if keys == {"ref"}:
26
+ return str(value["ref"])
27
+ if keys == {"expr"}:
28
+ return str(value["expr"])
29
+ if keys == {"var"}:
30
+ return f"__tc_vars__[{dict_to_python_compact(value['var'])}]"
31
+ pairs = [
32
+ f"{dict_to_python_compact(key)}: "
33
+ f"{render_flow_value(item, current_case_id=current_case_id, request_vars=request_vars)}"
34
+ for key, item in value.items()
35
+ ]
36
+ return "{" + ", ".join(pairs) + "}"
37
+ if isinstance(value, list):
38
+ return "[" + ", ".join(
39
+ render_flow_value(item, current_case_id=current_case_id, request_vars=request_vars)
40
+ for item in value
41
+ ) + "]"
42
+ return dict_to_python_compact(value)
43
+
44
+
45
+ def render_flow_call(
46
+ step: Any,
47
+ *,
48
+ current_case_id: str,
49
+ request_vars: dict[str, str],
50
+ ) -> str:
51
+ args = [
52
+ render_flow_value(item, current_case_id=current_case_id, request_vars=request_vars)
53
+ for item in step.args
54
+ ]
55
+ kwargs = [
56
+ f"{key}={render_flow_value(value, current_case_id=current_case_id, request_vars=request_vars)}"
57
+ for key, value in step.kwargs.items()
58
+ ]
59
+ params = ", ".join([*args, *kwargs])
60
+ call = f"{step.call}({params})"
61
+ return f"{step.save_as} = {call}" if step.save_as else call
@@ -0,0 +1,44 @@
1
+ """Shared rendering for generated pytest test functions."""
2
+ from __future__ import annotations
3
+
4
+ from typing import Any
5
+
6
+ from aitest_kit.codegen.render_utils import render_assignment, tc_func_name
7
+
8
+
9
+ def render_case_function(
10
+ *,
11
+ case_id: str,
12
+ title: str,
13
+ fixtures: list[str],
14
+ manual: bool,
15
+ metadata: dict[str, Any],
16
+ body_lines: list[str],
17
+ ) -> list[str]:
18
+ """Render a generated pytest test function with case identity context."""
19
+ lines: list[str] = []
20
+ if manual:
21
+ lines.append(" @pytest.mark.manual")
22
+
23
+ signature = ", ".join(["self", *fixtures])
24
+ lines.append(f" def {tc_func_name(case_id)}({signature}):")
25
+ lines.append(f' """{case_id}:{title}"""')
26
+ lines.extend(render_assignment("__tc_meta__", metadata, indent=2))
27
+ lines.append(
28
+ ' __aitest_ctx_token = set_case_context(__tc_meta__["tc_id"], __tc_meta__)'
29
+ )
30
+ lines.append(" try:")
31
+ rendered_body = [_indent_try_body_line(line) for line in body_lines]
32
+ if any(line.strip() for line in rendered_body):
33
+ lines.extend(rendered_body)
34
+ else:
35
+ lines.append(" pass")
36
+ lines.append(" finally:")
37
+ lines.append(" reset_case_context(__aitest_ctx_token)")
38
+ return lines
39
+
40
+
41
+ def _indent_try_body_line(line: str) -> str:
42
+ if not line:
43
+ return ""
44
+ return f" {line}"
@@ -23,12 +23,6 @@ class SourceTraceIR:
23
23
  reason: str = ""
24
24
 
25
25
 
26
- @dataclass
27
- class SetupCallIR:
28
- name: str
29
- kwargs: dict[str, Any] = field(default_factory=dict)
30
-
31
-
32
26
  @dataclass
33
27
  class RequestPatchIR:
34
28
  op: str
@@ -125,7 +119,6 @@ class CaseIR:
125
119
  protocol: str
126
120
  skip_reason: str | None = None
127
121
  fixtures: list[str] = field(default_factory=list)
128
- setup_call: SetupCallIR | None = None
129
122
  request: RequestIR | None = None
130
123
  request_bindings: dict[str, RequestBindingIR] = field(default_factory=dict)
131
124
  call: CallIR | None = None