测试代码顺序重排
testing.reorder
重新组织测试类和函数,使其顺序与被测试代码的顺序一致
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-02
- Stars
- ★ 155
- Forks
- 170
01 前言 Front Matter
- model
- haiku
- description
- Reorganize test classes and functions to match the order of the tested code
03 SKILL.md 正文
Goal
- Reorganize the Python test classes and functions in a testing file
*/test/test_*.pyto match the order of the functions they test in the corresponding source file
Conventions
- For all the code you must follow the instructions in
.claude/skills/coding.rules.md.claude/skills/testing.rules.md
Workflow
Find Test Code
- Find the functions in
<FILENAME>.pythat are tested in the filetest/test_<FILENAME>.py
Prepare a Plan
- Prepare a plan that shows a mapping between
- Test classes
- The functions tested by each class
- The file containing the tested functions
Order the Testing Classes in the Same Order as the Python File
-
Reorganize the code in
test/test_<FILENAME>.pyto match the order of the functions declared in<FILENAME>.py -
E.g., if in a Python
.../file.pydef test1(...) def test2(...)the corresponding
.../test/test_file.pyclass Test_test1(...) class Test_test2(...)
Preserve Behavior Exactly
- Do not modify functionality, logic, signatures, control flow, side effects, or semantics
- The resulting code must behave identically to the original
Move Code Only
- The refactor must be structural only
- Allowed changes:
- Reordering functions
- Adding section headers
- Renaming internal/private functions consistently
- Disallowed changes:
- Rewriting logic
- Simplifying implementations
- Changing APIs
- Changing imports unnecessarily
- Modifying formatting beyond what is required for reorganization
Implement the Plan
- Implement the plan moving the code without changing it
- Run the related unit tests to make sure everything works
Verification
- [ ] Confirm test classes appear in the same order as the functions they test
- [ ] Run the related unit tests and confirm they pass
- [ ] Confirm no logic, signatures, or behavior changed
04 同仓库更多 Skills
Docker 文件同步与模板对齐
tutorial_in_60_mins.propagate_docker_changes
同步教程和课程项目的 Docker 文件,使其与 project_template 保持一致。
Markdown 合并至 Jupyter Notebook
tutorial_in_60_mins.merge_markdown
将 Markdown 文件的内容合并到 Jupyter Notebook 中。
60 分钟教程格式规范化
tutorial_in_60_mins.format
格式化目录,使其遵循「Learn X in 60 Minutes」(60 分钟学会 X)教程约定。
60 分钟教程目录创建
tutorial_in_60_mins.create
按照「Learn X in 60 Minutes」(60 分钟学会 X)约定创建教程目录。
todo.reorg_in_progress
Reorganize ai_task_queue.md so in-progress tasks, not-started tasks, and mislabeled topic headers sit under the right H1 stage
todo.reorg_headers
Reorganize ai_task_queue.md .md so every H2 topic matches ALL TOPICS and every H3 task sits under the right topic, keeping its H1 stage