用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/causify-ai/helpers --skill testingfix-unit-tests命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | testing.fix_unit_tests |
| description | Refactor unit test files by aligning strings, renaming methods, and factoring out common test code |
Instead of this
def hello()
...
content = """<start:file1.txt>
Content for file1
<start:file2.txt>
Content for file2
"""
align the content of the string to the rest of the code
def hello()
...
content = """
<start:file1.txt>
Content for file1
<start:file2.txt>
Content for file2
"""
content = hprint.dedent(content)
test1, test2, ...Aggressively factor out common code in helper code so that each test method sets the inputs and the expected value and then calls the helper function with the common code
Instead of:
def test_first_line(self) -> None:
"""
Test position in first line returns line 1.
"""
# Prepare inputs.
content = "Line 1\nLine 2\nLine 3"
position = 3
# Run test.
actual = dshctsifi._get_line_number(content, position)
# Check outputs.
expected = 1
self.assertEqual(actual, expected)
def test_second_line(self) -> None:
"""
Test position in second line returns line 2.
"""
# Prepare inputs.
content = "Line 1\nLine 2\nLine 3"
position = 10
# Run test.
actual = dshctsifi._get_line_number(content, position)
# Check outputs.
expected = 2
self.assertEqual(actual, expected)
Do
def helper(self, content: str, position: int, expected: int) -> None:
# Run test.
actual = dshctsifi._get_line_number(content, position)
# Check outputs.
self.assertEqual(actual, expected)
def test1(self) -> None:
"""
Test position in first line returns line 1.
"""
# Prepare inputs.
content = "Line 1\nLine 2\nLine 3"
position = 3
expected = 1
# Run test.
self.helper(content, position, expected)
def test2(self) -> None:
"""
Test position in second line returns line 2.
"""
# Prepare inputs.
content = "Line 1\nLine 2\nLine 3"
position = 10
expected = 2
# Run test.
self.helper(content, position, expected)
var and expected need to always be the same (e.g., to show
that a variable doesn't change), instead of replicating the assignment, do an
assignment
expected = var
def test2(self) -> None:
"""
Test indented code block with correct indentation.
"""
# Prepare inputs.
txt = """
- Delete unused reference files
```bash
> rm Dockerfile.ubuntu
```
"""
# Expected: no changes needed.
expected = """
- Delete unused reference files
```bash
> rm Dockerfile.ubuntu
```
"""
# Run test.
self.helper(txt, expected)
def test2(self) -> None:
"""
Test indented code block with correct indentation.
"""
# Prepare inputs.
txt = """
- Delete unused reference files
```bash
> rm Dockerfile.ubuntu
```
"""
# Expected: no changes needed.
expected = txt
# Run test.
self.helper(txt, expected)