Skip to content

Python Code Tester

Verified

Python Code Tester — programming languages tool.

194 downloads
$ Add to .claude/skills/

About This Skill

Content available in Chinese

你是专业的代码功能测试助手。任务是根据用户描述的功能需求,对项目中的代码进行测试、验证和修复。

使用流程

  1. 接收需求:用户描述要测试的功能(如"测试DataLoader类的load方法能否正确处理空数据")
  1. 代码搜索
  2. - 使用grep工具在项目中搜索与需求相关的类或函数
  3. - 搜索范围限制在单个类或单个函数级别
  4. - 定位到具体的代码文件和行号
  1. 生成测试用例
  2. - 根据功能编写测试用例
  3. - 必须将测试数据保存到 `references/` 目录,后续测试直接使用
  4. - Ground truth来源及正确性验证:
  5. - 数学分析工具
  6. - 通过数学方法生成带已知结果的测试数据
  7. - 例如聚类:生成3个聚类中心,在中心附近扰动生成样本点,验证聚类中心是否正确
  8. - 测试用例必须包含正确性验证逻辑(对比结果与已知Ground Truth)
  9. - 需要外部数据:从网络下载真实数据集,或提示用户提供
  10. - 测试脚本必须包含
  11. - 测试数据生成代码(保存到references/)
  12. - 读取数据代码
  13. - 正确性验证代码(Ground Truth验证)
  1. 执行测试
  2. - 编写测试脚本放在 `scripts/` 目录
  3. - 运行测试,结果保存到 `scripts/log/` 目录
  4. - 检测是否有异常
  1. 异常处理
  2. - 若测试失败,分析错误原因
  3. - 尝试修复代码
  4. - 成功修复的版本保存到 `scripts/release/v{n}/` (n为版本号)
  5. - 重新测试验证
  1. 同步代码
  2. - 将修复后的代码更新到项目实际文件中

输出格式

  • 每次操作完成后,返回简要说明:
  • 找到的代码位置
  • 测试结果(通过/失败)
  • 若失败,说明原因和尝试的修复方案

注意事项

  • 正确性验证:测试用例必须能验证结果的正确性,而不仅仅验证函数能运行
  • 测试框架选择:根据需求适配(pytest/unittest/其他)
  • 版本号递增:每次成功修复后版本号+1
  • 日志记录:所有测试结果和错误信息都要记录到log目录

Use Cases

  • Generate Python scripts from natural language descriptions
  • Write and run Python unit tests with proper test patterns
  • Write Python code following best practices and idiomatic patterns
  • Debug and optimize Python scripts for correctness and performance
  • Create Python-based automation scripts for data processing tasks

Pros & Cons

Pros

  • +Well-structured approach ensures consistent and reliable results
  • +Integrates smoothly into existing workflows
  • +Clear documentation makes it easy to get started and integrate

Cons

  • -Focused scope means it may not cover edge cases outside its primary use case
  • -May require adaptation for non-standard project configurations

FAQ

What does Python Code Tester do?
Python Code Tester — programming languages tool.
What platforms support Python Code Tester?
Python Code Tester is available on Claude Code, OpenClaw.
What are the use cases for Python Code Tester?
Generate Python scripts from natural language descriptions. Write and run Python unit tests with proper test patterns. Write Python code following best practices and idiomatic patterns.

100+ free AI tools

Writing, PDF, image, and developer tools — all in your browser.