pytest-code-review
Reviews pytest test code for async patterns, fixtures, parametrize, and mocking. Use when reviewing test_*.py files, checking async test functions, fixture usage, or mock patterns.
Install via CLI (Recommended)
clawhub install openclaw/skills/skills/anderskev/pytest-code-reviewWhat This Skill Does
The pytest-code-review skill acts as an specialized auditing assistant for Python test suites utilizing the pytest framework. It focuses on modernizing and hardening test code by enforcing best practices for asynchronous operations, fixture management, and mocking strategies. By evaluating test functions against established patterns, it ensures that your test suite is not only robust but also maintainable and readable.
Installation
To integrate this skill into your OpenClaw environment, use the following command in your terminal:
clawhub install openclaw/skills/skills/anderskev/pytest-code-review
Ensure that you have the necessary permissions within your development environment and that the OpenClaw CLI is correctly authenticated.
Use Cases
- Legacy Code Refactoring: Use this skill to transition legacy synchronous tests that interact with async dependencies to proper
async def test_*patterns. - Fixture Optimization: Use it to analyze
conftest.pyfiles to determine if fixture scopes (function, class, module, or session) are inefficient and suggest cleanup improvements. - Mocking Cleanup: Identify incorrect usage of
Mockobjects whereAsyncMockis required, and verify that allpatch()targets are correctly scoped to prevent common test leakage issues. - DRY Code Enforcement: Detect repetitive test logic that could be collapsed into single parametrized functions using
@pytest.mark.parametrize.
Example Prompts
- "Review test_user_service.py and identify why my AsyncMock calls are not properly awaiting the results."
- "I have several duplicate test functions for different database edge cases; can you help me refactor these using parametrize?"
- "Check the fixtures in my conftest.py; are there any issues with the current scope configuration or potential resource leaks?"
Tips & Limitations
- Context is Key: Always provide the full file context or related
conftest.pyfiles to ensure the skill can verify patch targets and fixture availability accurately. - Not a Linter: While this skill checks for architectural and pattern issues, it does not replace static analysis tools like
pylintorflake8. Use them in tandem for the best results. - Security: Be mindful when granting file-read access to production codebases, although this skill is strictly for analyzing local test files. It will not execute your code, keeping the process safe.
Metadata
Not sure this is the right skill?
Describe what you want to build — we'll match you to the best skill from 16,000+ options.
Find the right skillPaste this into your clawhub.json to enable this plugin.
{
"plugins": {
"official-anderskev-pytest-code-review": {
"enabled": true,
"auto_update": true
}
}
}Tags(AI)
Flags: file-read
Related Skills
tutorial-docs
Tutorial patterns for documentation - learning-oriented guides that teach through guided doing
fetch-pr-feedback
Fetch review comments from a PR and evaluate with receive-feedback skill
swift-testing-code-review
Reviews Swift Testing code for proper use of
rust-testing-code-review
Reviews Rust test code for unit test patterns, integration test structure, async testing, mocking approaches, and property-based testing. Covers Rust 2024 edition changes including async fn in traits for mocks,
explanation-docs
Explanation documentation patterns for understanding-oriented content - conceptual guides that explain why things work the way they do