[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7BYYANP0KB80GAH60R6VR66":3,"skill-same:01M7BYYANP0KB80GAH60R6VR66":45},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M7BYYANP0KB80GAH60R6VR66","testing-python",null,"Write and evaluate effective Python tests using pytest. Use when writing tests, reviewing test code, debugging test failures, or improving test coverage. Covers test design, fixtures, parameterization, mocking, and async testing.","linyouxue\u002Fskill-repair-benchmark","linyouxue","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F216151464?v=4","01M7BJEVCXKD74KH6FG9CBVSQB","林宥学","01M7BJEVE02NP217V93BKZFC0J",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fevaluation\u002Fresults\u002FSkillAxe\u002Ftasks\u002Ffix-build-agentops\u002Frepaired_skill\u002Ftesting-python\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: testing-python\ndescription: Write and evaluate effective Python tests using pytest. Use when writing tests, reviewing test code, debugging test failures, or improving test coverage. Covers test design, fixtures, parameterization, mocking, and async testing.\n---\n\n# Writing Effective Python Tests\n\n## Core Principles\n\nEvery test should be **atomic**, **self-contained**, and test **single functionality**. A test that tests multiple things is harder to debug and maintain.\n\n## Debugging Test Failures (Practical Workflow)\n\nWhen a build fails, prioritize **matching the verifier's test harness** and **closing the exact assertion gap**.\n\n1. **Reproduce with the same runner\u002Ftooling**\n   - If the project uses **tox**, run the failing env(s) directly (e.g. `tox -e py311`).\n   - If the logs show `coverage run -m pytest`, reproduce that (coverage can change import timing and reveal state leaks).\n\n2. **Read the failure like a contract**\n   - Extract the *observable mismatch* (e.g. expected request count vs. actual, missing tags, warning emitted).\n   - Tie your fix to a specific, test-observable outcome.\n\n3. **Watch for shared state between tests**\n   - Common culprits: module-level singletons, cached clients\u002Fsessions, global registries, background threads\u002Fqueues.\n   - If you see warnings like “already started” or behavior that depends on test order, assume **state leakage** until proven otherwise.\n\n4. **Add\u002Fadjust resets at the correct boundary**\n   - Prefer making the library behavior correct\u002Frobust (idempotent start\u002Fstop, clear session lifecycle) over changing tests.\n   - If tests assume a clean global state, ensure the public API can reliably reach that state (e.g., `end_session()` truly ends, `start_session()` can start after end, tags\u002Fconfig persist as documented).\n\n5. **Validate with a full run**\n   - Run the whole suite (not just the one failing test) to catch regressions.\n\n## Test Structure\n\n### Atomic unit tests\n\nEach test should verify a single behavior. The test name should tell you what's broken when it fails. Multiple assertions are fine when they all verify the same behavior.\n\n```python\n# Good: Name tells you what's broken\ndef test_user_creation_sets_defaults():\n    user = User(name=\"Alice\")\n    assert user.role == \"member\"\n    assert user.id is not None\n    assert user.created_at is not None\n\n# Bad: If this fails, what behavior is broken?\ndef test_user():\n    user = User(name=\"Alice\")\n    assert user.role == \"member\"\n    user.promote()\n    assert user.role == \"admin\"\n    assert user.can_delete_others()\n```\n\n### Use parameterization for variations of the same concept\n\n```python\nimport pytest\n\n@pytest.mark.parametrize(\"input,expected\", [\n    (\"hello\", \"HELLO\"),\n    (\"World\", \"WORLD\"),\n    (\"\", \"\"),\n    (\"123\", \"123\"),\n])\ndef test_uppercase_conversion(input, expected):\n    assert input.upper() == expected\n```\n\n### Use separate tests for different functionality\n\nDon't parameterize unrelated behaviors. If the test logic differs, write separate tests.\n\n## Project-Specific Rules\n\n### No async markers needed\n\nThis project uses `asyncio_mode = \"auto\"` globally. Write async tests without decorators:\n\n```python\n# Correct\nasync def test_async_operation():\n    result = await some_async_function()\n    assert result == expected\n\n# Wrong - don't add this\n@pytest.mark.asyncio\nasync def test_async_operation():\n    ...\n```\n\n### Imports at module level\n\nPut ALL imports at the top of the file:\n\n```python\n# Correct\nimport pytest\nfrom fastmcp import FastMCP\nfrom fastmcp.client import Client\n\nasync def test_something():\n    mcp = FastMCP(\"test\")\n    ...\n\n# Wrong - no local imports\nasync def test_something():\n    from fastmcp import FastMCP  # Don't do this\n    ...\n```\n\n### Use in-memory transport for testing\n\nPass FastMCP servers directly to clients:\n\n```python\nfrom fastmcp import FastMCP\nfrom fastmcp.client import Client\n\nmcp = FastMCP(\"TestServer\")\n\n@mcp.tool\ndef greet(name: str) -> str:\n    return f\"Hello, {name}!\"\n\nasync def test_greet_tool():\n    async with Client(mcp) as client:\n        result = await client.call_tool(\"greet\", {\"name\": \"World\"})\n        assert result[0].text == \"Hello, World!\"\n```\n\nOnly use HTTP transport when explicitly testing network features.\n\n### Inline snapshots for complex data\n\nUse `inline-snapshot` for testing JSON schemas and complex structures:\n\n```python\nfrom inline_snapshot import snapshot\n\ndef test_schema_generation():\n    schema = generate_schema(MyModel)\n    assert schema == snapshot()  # Will auto-populate on first run\n```\n\nCommands:\n- `pytest --inline-snapshot=create` - populate empty snapshots\n- `pytest --inline-snapshot=fix` - update after intentional changes\n\n## Fixtures\n\n### Prefer function-scoped fixtures\n\n```python\n@pytest.fixture\ndef client():\n    return Client()\n\nasync def test_with_client(client):\n    result = await client.ping()\n    assert result is not None\n```\n\n### Use `tmp_path` for file operations\n\n```python\ndef test_file_writing(tmp_path):\n    file = tmp_path \u002F \"test.txt\"\n    file.write_text(\"content\")\n    assert file.read_text() == \"content\"\n```\n\n### Explicitly manage global\u002Fsingleton state when present\n\nIf the code under test uses a module-level singleton (client\u002Fsession), add explicit setup\u002Fteardown steps:\n\n- Ensure each test starts from a known state.\n- Prefer public APIs for reset\u002Fstop; if none exist, consider adding a safe reset hook in the library.\n- Symptoms that indicate missing reset:\n  - warnings like “session already started”\n  - request counts depending on test order\n  - missing\u002Fold config leaking into later tests\n\n## Mocking\n\n### Mock at the boundary\n\n```python\nfrom unittest.mock import patch, AsyncMock\n\nasync def test_external_api_call():\n    with patch(\"mymodule.external_client.fetch\", new_callable=AsyncMock) as mock:\n        mock.return_value = {\"data\": \"test\"}\n        result = await my_function()\n        assert result == {\"data\": \"test\"}\n```\n\n### Don't mock what you own\n\nTest your code with real implementations when possible. Mock external services, not internal classes.\n\n## Test Naming\n\nUse descriptive names that explain the scenario:\n\n```python\n# Good\ndef test_login_fails_with_invalid_password():\ndef test_user_can_update_own_profile():\ndef test_admin_can_delete_any_user():\n\n# Bad\ndef test_login():\ndef test_update():\ndef test_delete():\n```\n\n## Error Testing\n\n```python\nimport pytest\n\ndef test_raises_on_invalid_input():\n    with pytest.raises(ValueError, match=\"must be positive\"):\n        calculate(-1)\n\nasync def test_async_raises():\n    with pytest.raises(ConnectionError):\n        await connect_to_invalid_host()\n```\n\n## Running Tests\n\n```bash\nuv run pytest -n auto              # Run all tests in parallel\nuv run pytest -n auto -x           # Stop on first failure\nuv run pytest path\u002Fto\u002Ftest.py      # Run specific file\nuv run pytest -k \"test_name\"       # Run tests matching pattern\nuv run pytest -m \"not integration\" # Exclude integration tests\n```\n\n### If the project uses tox\u002Fcoverage, mirror it\n\n```bash\n# Run a specific tox env that matches CI\ntox -e py311\n\n# Or mirror the exact command shown in CI logs\ncoverage run --source \u003Cpackage> -m pytest\ncoverage report -m\n```\n\n## Checklist\n\nBefore submitting tests or fixes:\n- [ ] I reproduced failures with the same harness (tox\u002Fcoverage\u002Fpytest flags) used by CI\n- [ ] Each test tests one thing\n- [ ] No `@pytest.mark.asyncio` decorators (unless project explicitly requires it)\n- [ ] Imports at module level\n- [ ] Descriptive test names\n- [ ] Using in-memory transport (not HTTP) unless testing networking\n- [ ] Parameterization for variations of same behavior\n- [ ] Separate tests for different behaviors\n- [ ] If failures suggest state leakage (\"already started\"), I verified singleton\u002Fsession lifecycle correctness\n","# Writing Effective Python Tests\n\n## Core Principles\n\nEvery test should be **atomic**, **self-contained**, and test **single functionality**. A test that tests multiple things is harder to debug and maintain.\n\n## Debugging Test Failures (Practical Workflow)\n\nWhen a build fails, prioritize **matching the verifier's test harness** and **closing the exact assertion gap**.\n\n1. **Reproduce with the same runner\u002Ftooling**\n   - If the project uses **tox**, run the failing env(s) directly (e.g. `tox -e py311`).\n   - If the logs show `coverage run -m pytest`, reproduce that (coverage can change import timing and reveal state leaks).\n\n2. **Read the failure like a contract**\n   - Extract the *observable mismatch* (e.g. expected request count vs. actual, missing tags, warning emitted).\n   - Tie your fix to a specific, test-observable outcome.\n\n3. **Watch for shared state between tests**\n   - Common culprits: module-level singletons, cached clients\u002Fsessions, global registries, background threads\u002Fqueues.\n   - If you see warnings like “already started” or behavior that depends on test order, assume **state leakage** until proven otherwise.\n\n4. **Add\u002Fadjust resets at the correct boundary**\n   - Prefer making the library behavior correct\u002Frobust (idempotent start\u002Fstop, clear session lifecycle) over changing tests.\n   - If tests assume a clean global state, ensure the public API can reliably reach that state (e.g., `end_session()` truly ends, `start_session()` can start after end, tags\u002Fconfig persist as documented).\n\n5. **Validate with a full run**\n   - Run the whole suite (not just the one failing test) to catch regressions.\n\n## Test Structure\n\n### Atomic unit tests\n\nEach test should verify a single behavior. The test name should tell you what's broken when it fails. Multiple assertions are fine when they all verify the same behavior.\n\n```python\n# Good: Name tells you what's broken\ndef test_user_creation_sets_defaults():\n    user = User(name=\"Alice\")\n    assert user.role == \"member\"\n    assert user.id is not None\n    assert user.created_at is not None\n\n# Bad: If this fails, what behavior is broken?\ndef test_user():\n    user = User(name=\"Alice\")\n    assert user.role == \"member\"\n    user.promote()\n    assert user.role == \"admin\"\n    assert user.can_delete_others()\n```\n\n### Use parameterization for variations of the same concept\n\n```python\nimport pytest\n\n@pytest.mark.parametrize(\"input,expected\", [\n    (\"hello\", \"HELLO\"),\n    (\"World\", \"WORLD\"),\n    (\"\", \"\"),\n    (\"123\", \"123\"),\n])\ndef test_uppercase_conversion(input, expected):\n    assert input.upper() == expected\n```\n\n### Use separate tests for different functionality\n\nDon't parameterize unrelated behaviors. If the test logic differs, write separate tests.\n\n## Project-Specific Rules\n\n### No async markers needed\n\nThis project uses `asyncio_mode = \"auto\"` globally. Write async tests without decorators:\n\n```python\n# Correct\nasync def test_async_operation():\n    result = await some_async_function()\n    assert result == expected\n\n# Wrong - don't add this\n@pytest.mark.asyncio\nasync def test_async_operation():\n    ...\n```\n\n### Imports at module level\n\nPut ALL imports at the top of the file:\n\n```python\n# Correct\nimport pytest\nfrom fastmcp import FastMCP\nfrom fastmcp.client import Client\n\nasync def test_something():\n    mcp = FastMCP(\"test\")\n    ...\n\n# Wrong - no local imports\nasync def test_something():\n    from fastmcp import FastMCP  # Don't do this\n    ...\n```\n\n### Use in-memory transport for testing\n\nPass FastMCP servers directly to clients:\n\n```python\nfrom fastmcp import FastMCP\nfrom fastmcp.client import Client\n\nmcp = FastMCP(\"TestServer\")\n\n@mcp.tool\ndef greet(name: str) -> str:\n    return f\"Hello, {name}!\"\n\nasync def test_greet_tool():\n    async with Client(mcp) as client:\n        result = await client.call_tool(\"greet\", {\"name\": \"World\"})\n        assert result[0].text == \"Hello, World!\"\n```\n\nOnly use HTTP transport when explicitly testing network features.\n\n### Inline snapshots for complex data\n\nUse `inline-snapshot` for testing JSON schemas and complex structures:\n\n```python\nfrom inline_snapshot import snapshot\n\ndef test_schema_generation():\n    schema = generate_schema(MyModel)\n    assert schema == snapshot()  # Will auto-populate on first run\n```\n\nCommands:\n- `pytest --inline-snapshot=create` - populate empty snapshots\n- `pytest --inline-snapshot=fix` - update after intentional changes\n\n## Fixtures\n\n### Prefer function-scoped fixtures\n\n```python\n@pytest.fixture\ndef client():\n    return Client()\n\nasync def test_with_client(client):\n    result = await client.ping()\n    assert result is not None\n```\n\n### Use `tmp_path` for file operations\n\n```python\ndef test_file_writing(tmp_path):\n    file = tmp_path \u002F \"test.txt\"\n    file.write_text(\"content\")\n    assert file.read_text() == \"content\"\n```\n\n### Explicitly manage global\u002Fsingleton state when present\n\nIf the code under test uses a module-level singleton (client\u002Fsession), add explicit setup\u002Fteardown steps:\n\n- Ensure each test starts from a known state.\n- Prefer public APIs for reset\u002Fstop; if none exist, consider adding a safe reset hook in the library.\n- Symptoms that indicate missing reset:\n  - warnings like “session already started”\n  - request counts depending on test order\n  - missing\u002Fold config leaking into later tests\n\n## Mocking\n\n### Mock at the boundary\n\n```python\nfrom unittest.mock import patch, AsyncMock\n\nasync def test_external_api_call():\n    with patch(\"mymodule.external_client.fetch\", new_callable=AsyncMock) as mock:\n        mock.return_value = {\"data\": \"test\"}\n        result = await my_function()\n        assert result == {\"data\": \"test\"}\n```\n\n### Don't mock what you own\n\nTest your code with real implementations when possible. Mock external services, not internal classes.\n\n## Test Naming\n\nUse descriptive names that explain the scenario:\n\n```python\n# Good\ndef test_login_fails_with_invalid_password():\ndef test_user_can_update_own_profile():\ndef test_admin_can_delete_any_user():\n\n# Bad\ndef test_login():\ndef test_update():\ndef test_delete():\n```\n\n## Error Testing\n\n```python\nimport pytest\n\ndef test_raises_on_invalid_input():\n    with pytest.raises(ValueError, match=\"must be positive\"):\n        calculate(-1)\n\nasync def test_async_raises():\n    with pytest.raises(ConnectionError):\n        await connect_to_invalid_host()\n```\n\n## Running Tests\n\n```bash\nuv run pytest -n auto              # Run all tests in parallel\nuv run pytest -n auto -x           # Stop on first failure\nuv run pytest path\u002Fto\u002Ftest.py      # Run specific file\nuv run pytest -k \"test_name\"       # Run tests matching pattern\nuv run pytest -m \"not integration\" # Exclude integration tests\n```\n\n### If the project uses tox\u002Fcoverage, mirror it\n\n```bash\n# Run a specific tox env that matches CI\ntox -e py311\n\n# Or mirror the exact command shown in CI logs\ncoverage run --source \u003Cpackage> -m pytest\ncoverage report -m\n```\n\n## Checklist\n\nBefore submitting tests or fixes:\n- [ ] I reproduced failures with the same harness (tox\u002Fcoverage\u002Fpytest flags) used by CI\n- [ ] Each test tests one thing\n- [ ] No `@pytest.mark.asyncio` decorators (unless project explicitly requires it)\n- [ ] Imports at module level\n- [ ] Descriptive test names\n- [ ] Using in-memory transport (not HTTP) unless testing networking\n- [ ] Parameterization for variations of same behavior\n- [ ] Separate tests for different behaviors\n- [ ] If failures suggest state leakage (\"already started\"), I verified singleton\u002Fsession lifecycle correctness\n",{"name":5,"description":7},"main","cdcb6d230f3b15c3c33f8a2bdd16439f43602cbe","evaluation\u002Fresults\u002FSkillAxe\u002Ftasks\u002Ffix-build-agentops\u002Frepaired_skill\u002Ftesting-python",1,"https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark","https:\u002F\u002Fgithub.com\u002Flinyouxue","2026-11-14 20:28:35",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add linyouxue\u002Fskill-repair-benchmark --skill testing-python",{"tool":37,"command":38},"bunx","bunx skills add linyouxue\u002Fskill-repair-benchmark --skill testing-python",{"tool":40,"command":41},"pnpm","pnpm dlx skills add linyouxue\u002Fskill-repair-benchmark --skill testing-python","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fevaluation\u002Fresults\u002FSkillAxe\u002Ftasks\u002Ffix-build-agentops\u002Frepaired_skill\u002Ftesting-python\u002FSKILL.md",true,[],[46,53,60,67,72,77],{"skillNo":47,"name":48,"nameZh":6,"description":49,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":50,"categories":51,"keywords":52,"publishedAt":19},"01M7E1HGVRY73NBJ022CJG13X6","video-frame-extraction","Extract frames from video files and save them as images using OpenCV","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_03\u002Finputs\u002Fskills\u002Fvideo-frame-extraction\u002FSKILL.md",[],[],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":19},"01M7E1HAG5R7CJ9C8NYJS771MB","openai-vision","Analyze images and multi-frame sequences using OpenAI GPT vision models","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_03\u002Finputs\u002Fskills\u002Fopenai-vision\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":19},"01M7E1H7DADKB6QBWKC2KQ63SZ","image-ocr","Extract text content from images using Tesseract OCR via Python, including structured field extraction from receipts and forms","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_03\u002Finputs\u002Fskills\u002Fimage-ocr\u002FSKILL.md",[],[],{"skillNo":68,"name":48,"nameZh":6,"description":49,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":19},"01M7E1H0WBNT43TENGQY7AVZHD","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_02\u002Finputs\u002Fskills\u002Fvideo-frame-extraction\u002FSKILL.md",[],[],{"skillNo":73,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M7E1GTC7D4N4Q2EF03875J9E","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_02\u002Finputs\u002Fskills\u002Fopenai-vision\u002FSKILL.md",[],[],{"skillNo":78,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":19},"01M7E1GQ92CWFMGH53KSSE4WER","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_02\u002Finputs\u002Fskills\u002Fimage-ocr\u002FSKILL.md",[],[]]